@google-cloud/spanner 6.4.0 → 6.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/nodejs-spanner?activeTab=versions
6
6
 
7
+ ## [6.6.0](https://github.com/googleapis/nodejs-spanner/compare/v6.5.0...v6.6.0) (2022-12-16)
8
+
9
+
10
+ ### Features
11
+
12
+ * Export data types in index.ts ([#1726](https://github.com/googleapis/nodejs-spanner/issues/1726)) ([844f57f](https://github.com/googleapis/nodejs-spanner/commit/844f57fa5e79e5e5a5ede80df5e117004427f201)), closes [#1720](https://github.com/googleapis/nodejs-spanner/issues/1720)
13
+ * Fgac support and samples ([#1751](https://github.com/googleapis/nodejs-spanner/issues/1751)) ([0a394df](https://github.com/googleapis/nodejs-spanner/commit/0a394df9bfa193d79edc4c3a3d26238f361c0d45))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * Add sleep after admin request intensive tests ([#1758](https://github.com/googleapis/nodejs-spanner/issues/1758)) ([7643ceb](https://github.com/googleapis/nodejs-spanner/commit/7643ceb7cde9f420539877b86fdb0d38b254348d))
19
+
20
+ ## [6.5.0](https://github.com/googleapis/nodejs-spanner/compare/v6.4.0...v6.5.0) (2022-11-30)
21
+
22
+
23
+ ### Features
24
+
25
+ * Inline BeginTransaction with first statement ([#1692](https://github.com/googleapis/nodejs-spanner/issues/1692)) ([d1b95d2](https://github.com/googleapis/nodejs-spanner/commit/d1b95d21e2c8cb0eff88351265cad248870bb3ea))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * Cleanup different types of session pools ([#1739](https://github.com/googleapis/nodejs-spanner/issues/1739)) ([6f55187](https://github.com/googleapis/nodejs-spanner/commit/6f551877ea0d4b67e3c734377bdadd5d570cf839))
31
+ * **deps:** Use google-gax v3.5.2 ([#1732](https://github.com/googleapis/nodejs-spanner/issues/1732)) ([8341b1f](https://github.com/googleapis/nodejs-spanner/commit/8341b1fa5dfcf0b286892efb8b57c7ad694cdbb8))
32
+
7
33
  ## [6.4.0](https://github.com/googleapis/nodejs-spanner/compare/v6.3.0...v6.4.0) (2022-10-27)
8
34
 
9
35
 
package/README.md CHANGED
@@ -89,6 +89,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
89
89
 
90
90
  | Sample | Source Code | Try it |
91
91
  | --------------------------- | --------------------------------- | ------ |
92
+ | Add and drop new database role | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/add-and-drop-new-database-role.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/add-and-drop-new-database-role.js,samples/README.md) |
92
93
  | Backups-cancel | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/backups-cancel.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/backups-cancel.js,samples/README.md) |
93
94
  | Copies a source backup | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/backups-copy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/backups-copy.js,samples/README.md) |
94
95
  | Backups-create-with-encryption-key | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/backups-create-with-encryption-key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/backups-create-with-encryption-key.js,samples/README.md) |
@@ -111,7 +112,9 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
111
112
  | Updates the default leader of an existing database | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-update-default-leader.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-update-default-leader.js,samples/README.md) |
112
113
  | Datatypes | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/datatypes.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/datatypes.js,samples/README.md) |
113
114
  | DML | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/dml.js,samples/README.md) |
115
+ | Enable fine grained access control | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/enable-fine-grained-access.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/enable-fine-grained-access.js,samples/README.md) |
114
116
  | Get-commit-stats | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-commit-stats.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-commit-stats.js,samples/README.md) |
117
+ | List database roles | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-database-roles.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-database-roles.js,samples/README.md) |
115
118
  | Gets the instance config metadata for the configuration nam6 | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-instance-config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-instance-config.js,samples/README.md) |
116
119
  | Creates a new value-storing index | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/index-create-storing.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/index-create-storing.js,samples/README.md) |
117
120
  | Creates a new index | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/index-create.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/index-create.js,samples/README.md) |
@@ -153,6 +156,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
153
156
  | Query the information schema metadata in a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-schema-information.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-schema-information.js,samples/README.md) |
154
157
  | Queryoptions | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/queryoptions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/queryoptions.js,samples/README.md) |
155
158
  | Quickstart | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
159
+ | Read data with database role | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/read-data-with-database-role.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/read-data-with-database-role.js,samples/README.md) |
156
160
  | Sets a request tag for a single query | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/request-tag.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/request-tag.js,samples/README.md) |
157
161
  | Run Batch update with RPC priority | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/rpc-priority-batch-dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/rpc-priority-batch-dml.js,samples/README.md) |
158
162
  | Run partitioned update with RPC priority | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/rpc-priority-partitioned-dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/rpc-priority-partitioned-dml.js,samples/README.md) |
@@ -19,12 +19,12 @@ import { CallOptions, Metadata, Operation as GaxOperation } from 'google-gax';
19
19
  import { PreciseDate } from '@google-cloud/precise-date';
20
20
  import { google as databaseAdmin } from '../protos/protos';
21
21
  import { common as p } from 'protobufjs';
22
- export declare type CreateBackupCallback = LongRunningCallback<Backup>;
23
- export declare type CopyBackupCallback = LongRunningCallback<Backup>;
22
+ export type CreateBackupCallback = LongRunningCallback<Backup>;
23
+ export type CopyBackupCallback = LongRunningCallback<Backup>;
24
24
  export interface CreateBackupGaxOperation extends GaxOperation {
25
25
  metadata: Metadata & databaseAdmin.spanner.admin.database.v1.ICreateBackupMetadata;
26
26
  }
27
- export declare type CreateBackupResponse = [
27
+ export type CreateBackupResponse = [
28
28
  Backup,
29
29
  CreateBackupGaxOperation,
30
30
  IOperation
@@ -39,25 +39,25 @@ export interface CreateBackupOptions {
39
39
  export interface CopyBackupGaxOperation extends GaxOperation {
40
40
  metadata: Metadata & databaseAdmin.spanner.admin.database.v1.ICopyBackupMetadata;
41
41
  }
42
- export declare type CopyBackupResponse = [Backup, CopyBackupGaxOperation, IOperation];
42
+ export type CopyBackupResponse = [Backup, CopyBackupGaxOperation, IOperation];
43
43
  export interface CopyBackupOptions extends databaseAdmin.spanner.admin.database.v1.ICopyBackupRequest {
44
44
  gaxOptions?: CallOptions;
45
45
  }
46
46
  /**
47
47
  * IBackup structure with backup state enum translated to string form.
48
48
  */
49
- declare type IBackupTranslatedEnum = TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IBackup, 'state', typeof databaseAdmin.spanner.admin.database.v1.Backup.State>;
50
- export declare type GetMetadataResponse = [IBackupTranslatedEnum];
51
- declare type GetMetadataCallback = RequestCallback<IBackupTranslatedEnum>;
52
- declare type UpdateExpireTimeCallback = RequestCallback<databaseAdmin.spanner.admin.database.v1.IBackup>;
53
- declare type DeleteCallback = RequestCallback<databaseAdmin.protobuf.IEmpty>;
49
+ type IBackupTranslatedEnum = TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IBackup, 'state', typeof databaseAdmin.spanner.admin.database.v1.Backup.State>;
50
+ export type GetMetadataResponse = [IBackupTranslatedEnum];
51
+ type GetMetadataCallback = RequestCallback<IBackupTranslatedEnum>;
52
+ type UpdateExpireTimeCallback = RequestCallback<databaseAdmin.spanner.admin.database.v1.IBackup>;
53
+ type DeleteCallback = RequestCallback<databaseAdmin.protobuf.IEmpty>;
54
54
  interface BackupRequest {
55
55
  (config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
56
56
  <T>(config: RequestConfig, callback: RequestCallback<T>): void;
57
57
  }
58
- export declare type GetStateCallback = NormalCallback<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Backup.State>>;
59
- export declare type GetExpireTimeCallback = NormalCallback<PreciseDate>;
60
- export declare type ExistsCallback = NormalCallback<boolean>;
58
+ export type GetStateCallback = NormalCallback<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Backup.State>>;
59
+ export type GetExpireTimeCallback = NormalCallback<PreciseDate>;
60
+ export type ExistsCallback = NormalCallback<boolean>;
61
61
  /**
62
62
  * The {@link Backup} class represents a Cloud Spanner backup.
63
63
  *
@@ -1,7 +1,7 @@
1
1
  import { Big } from 'big.js';
2
2
  import { common as p } from 'protobufjs';
3
3
  import { google as spannerClient } from '../protos/protos';
4
- export declare type Value = any;
4
+ export type Value = any;
5
5
  export interface Field {
6
6
  name: string;
7
7
  value: Value;
@@ -16,13 +16,13 @@
16
16
  import { grpc, CallOptions, Operation as GaxOperation } from 'google-gax';
17
17
  import { google as instanceAdmin } from '../protos/protos';
18
18
  import { google as databaseAdmin } from '../protos/protos';
19
- export declare type IOperation = instanceAdmin.longrunning.IOperation;
20
- export declare type Schema = string | string[] | databaseAdmin.spanner.admin.database.v1.IUpdateDatabaseDdlRequest;
19
+ export type IOperation = instanceAdmin.longrunning.IOperation;
20
+ export type Schema = string | string[] | databaseAdmin.spanner.admin.database.v1.IUpdateDatabaseDdlRequest;
21
21
  export interface ResourceCallback<Resource, Response> {
22
22
  (err: grpc.ServiceError | null, resource?: Resource | null, response?: Response): void;
23
23
  }
24
- export declare type PagedResponse<Item, Response> = [Item[], {} | null, Response];
25
- export declare type RequestCallback<T, R = void> = R extends void ? NormalCallback<T> : PagedCallback<T, R>;
24
+ export type PagedResponse<Item, Response> = [Item[], {} | null, Response];
25
+ export type RequestCallback<T, R = void> = R extends void ? NormalCallback<T> : PagedCallback<T, R>;
26
26
  export interface NormalCallback<TResponse> {
27
27
  (err: grpc.ServiceError | null, res?: TResponse | null): void;
28
28
  }
@@ -31,49 +31,64 @@ import { AsyncRunTransactionCallback, RunTransactionCallback, RunTransactionOpti
31
31
  import { IOperation, LongRunningCallback, NormalCallback, PagedOptionsWithFilter, PagedResponse, RequestCallback, ResourceCallback, Schema } from './common';
32
32
  import { Duplex, Readable } from 'stream';
33
33
  import { EnumKey, RequestConfig, TranslateEnumKeys } from '.';
34
- declare type CreateBatchTransactionCallback = ResourceCallback<BatchTransaction, google.spanner.v1.ITransaction | google.spanner.v1.ISession>;
35
- declare type CreateBatchTransactionResponse = [
34
+ import IPolicy = google.iam.v1.IPolicy;
35
+ import Policy = google.iam.v1.Policy;
36
+ import FieldMask = google.protobuf.FieldMask;
37
+ export type GetDatabaseRolesCallback = RequestCallback<IDatabaseRole, databaseAdmin.spanner.admin.database.v1.IListDatabaseRolesResponse>;
38
+ export type GetDatabaseRolesResponse = PagedResponse<IDatabaseRole, databaseAdmin.spanner.admin.database.v1.IListDatabaseRolesResponse>;
39
+ type IDatabaseRole = databaseAdmin.spanner.admin.database.v1.IDatabaseRole;
40
+ type CreateBatchTransactionCallback = ResourceCallback<BatchTransaction, google.spanner.v1.ITransaction | google.spanner.v1.ISession>;
41
+ type CreateBatchTransactionResponse = [
36
42
  BatchTransaction,
37
43
  google.spanner.v1.ITransaction | google.spanner.v1.ISession
38
44
  ];
39
- declare type DatabaseResponse = [Database, r.Response];
40
- declare type DatabaseCallback = ResourceCallback<Database, r.Response>;
41
- declare type GetSnapshotCallback = NormalCallback<Snapshot>;
42
- declare type GetTransactionCallback = NormalCallback<Transaction>;
45
+ type DatabaseResponse = [Database, r.Response];
46
+ type DatabaseCallback = ResourceCallback<Database, r.Response>;
47
+ type GetSnapshotCallback = NormalCallback<Snapshot>;
48
+ type GetTransactionCallback = NormalCallback<Transaction>;
43
49
  export interface SessionPoolConstructor {
44
50
  new (database: Database, options?: SessionPoolOptions | null): SessionPoolInterface;
45
51
  }
46
- export declare type UpdateSchemaCallback = ResourceCallback<GaxOperation, databaseAdmin.longrunning.IOperation>;
47
- export declare type UpdateSchemaResponse = [
52
+ export interface SetIamPolicyRequest {
53
+ policy: Policy | null;
54
+ updateMask?: FieldMask | null;
55
+ }
56
+ export type UpdateSchemaCallback = ResourceCallback<GaxOperation, databaseAdmin.longrunning.IOperation>;
57
+ export type UpdateSchemaResponse = [
48
58
  GaxOperation,
49
59
  databaseAdmin.longrunning.IOperation
50
60
  ];
51
- declare type PoolRequestCallback = RequestCallback<Session>;
52
- export declare type GetSessionsOptions = PagedOptionsWithFilter;
61
+ type PoolRequestCallback = RequestCallback<Session>;
62
+ export type GetSessionsOptions = PagedOptionsWithFilter;
63
+ export type GetDatabaseRolesOptions = PagedOptionsWithFilter;
53
64
  /**
54
65
  * IDatabase structure with database state enum translated to string form.
55
66
  */
56
- declare type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & {
67
+ type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & {
57
68
  restoreInfo?: IRestoreInfoTranslatedEnum | null;
58
69
  };
59
70
  /**
60
71
  * IRestoreInfo structure with restore source type enum translated to string form.
61
72
  */
62
- declare type IRestoreInfoTranslatedEnum = TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IRestoreInfo, 'sourceType', typeof databaseAdmin.spanner.admin.database.v1.RestoreSourceType>;
63
- declare type GetDatabaseMetadataResponse = [IDatabaseTranslatedEnum];
64
- declare type GetDatabaseMetadataCallback = RequestCallback<IDatabaseTranslatedEnum>;
65
- declare type GetSchemaCallback = RequestCallback<string, databaseAdmin.spanner.admin.database.v1.IGetDatabaseDdlResponse>;
66
- declare type GetSchemaResponse = [
73
+ type IRestoreInfoTranslatedEnum = TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IRestoreInfo, 'sourceType', typeof databaseAdmin.spanner.admin.database.v1.RestoreSourceType>;
74
+ type GetDatabaseMetadataResponse = [IDatabaseTranslatedEnum];
75
+ type GetDatabaseMetadataCallback = RequestCallback<IDatabaseTranslatedEnum>;
76
+ type GetSchemaCallback = RequestCallback<string, databaseAdmin.spanner.admin.database.v1.IGetDatabaseDdlResponse>;
77
+ type GetSchemaResponse = [
67
78
  string[],
68
79
  databaseAdmin.spanner.admin.database.v1.IGetDatabaseDdlResponse
69
80
  ];
70
- declare type GetSessionsCallback = RequestCallback<Session, google.spanner.v1.IListSessionsResponse>;
71
- declare type GetSessionsResponse = PagedResponse<Session, google.spanner.v1.IListSessionsResponse>;
72
- export declare type GetDatabaseConfig = GetConfig & databaseAdmin.spanner.admin.database.v1.IGetDatabaseRequest & {
81
+ type GetIamPolicyResponse = IPolicy;
82
+ type GetIamPolicyCallback = RequestCallback<IPolicy>;
83
+ type SetIamPolicyResponse = IPolicy;
84
+ type SetIamPolicyCallback = RequestCallback<IPolicy>;
85
+ type GetSessionsCallback = RequestCallback<Session, google.spanner.v1.IListSessionsResponse>;
86
+ type GetSessionsResponse = PagedResponse<Session, google.spanner.v1.IListSessionsResponse>;
87
+ export type GetDatabaseConfig = GetConfig & databaseAdmin.spanner.admin.database.v1.IGetDatabaseRequest & {
73
88
  gaxOptions?: CallOptions;
74
89
  };
75
- declare type DatabaseCloseResponse = [google.protobuf.IEmpty];
76
- export declare type CreateSessionResponse = [
90
+ type DatabaseCloseResponse = [google.protobuf.IEmpty];
91
+ export type CreateSessionResponse = [
77
92
  Session,
78
93
  spannerClient.spanner.v1.ISession
79
94
  ];
@@ -81,30 +96,35 @@ export interface CreateSessionOptions {
81
96
  labels?: {
82
97
  [k: string]: string;
83
98
  } | null;
99
+ databaseRole?: string | null;
100
+ gaxOptions?: CallOptions;
101
+ }
102
+ export interface GetIamPolicyOptions {
103
+ requestedPolicyVersion?: number | null;
84
104
  gaxOptions?: CallOptions;
85
105
  }
86
- export declare type CreateSessionCallback = ResourceCallback<Session, spannerClient.spanner.v1.ISession>;
106
+ export type CreateSessionCallback = ResourceCallback<Session, spannerClient.spanner.v1.ISession>;
87
107
  export interface BatchCreateSessionsOptions extends CreateSessionOptions {
88
108
  count: number;
89
109
  }
90
- export declare type BatchCreateSessionsResponse = [
110
+ export type BatchCreateSessionsResponse = [
91
111
  Session[],
92
112
  spannerClient.spanner.v1.IBatchCreateSessionsResponse
93
113
  ];
94
- export declare type BatchCreateSessionsCallback = ResourceCallback<Session[], spannerClient.spanner.v1.IBatchCreateSessionsResponse>;
95
- export declare type DatabaseDeleteResponse = [databaseAdmin.protobuf.IEmpty];
96
- export declare type DatabaseDeleteCallback = NormalCallback<databaseAdmin.protobuf.IEmpty>;
114
+ export type BatchCreateSessionsCallback = ResourceCallback<Session[], spannerClient.spanner.v1.IBatchCreateSessionsResponse>;
115
+ export type DatabaseDeleteResponse = [databaseAdmin.protobuf.IEmpty];
116
+ export type DatabaseDeleteCallback = NormalCallback<databaseAdmin.protobuf.IEmpty>;
97
117
  export interface CancelableDuplex extends Duplex {
98
118
  cancel(): void;
99
119
  }
100
- export declare type RestoreDatabaseCallback = LongRunningCallback<Database>;
101
- export declare type RestoreDatabaseResponse = [
120
+ export type RestoreDatabaseCallback = LongRunningCallback<Database>;
121
+ export type RestoreDatabaseResponse = [
102
122
  Database,
103
123
  GaxOperation,
104
124
  databaseAdmin.longrunning.IOperation
105
125
  ];
106
- export declare type GetRestoreInfoCallback = NormalCallback<IRestoreInfoTranslatedEnum>;
107
- export declare type GetStateCallback = NormalCallback<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Database.State>>;
126
+ export type GetRestoreInfoCallback = NormalCallback<IRestoreInfoTranslatedEnum>;
127
+ export type GetStateCallback = NormalCallback<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Database.State>>;
108
128
  interface DatabaseRequest {
109
129
  (config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
110
130
  <T>(config: RequestConfig, callback: RequestCallback<T>): void;
@@ -142,6 +162,7 @@ declare class Database extends common.GrpcServiceObject {
142
162
  [k: string]: string;
143
163
  };
144
164
  request: DatabaseRequest;
165
+ databaseRole?: string | null;
145
166
  constructor(instance: Instance, name: string, poolOptions?: SessionPoolConstructor | SessionPoolOptions, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions);
146
167
  static getEnvironmentQueryOptions(): databaseAdmin.spanner.v1.ExecuteSqlRequest.IQueryOptions;
147
168
  /**
@@ -772,6 +793,53 @@ declare class Database extends common.GrpcServiceObject {
772
793
  getSchema(options?: CallOptions): Promise<GetSchemaResponse>;
773
794
  getSchema(callback: GetSchemaCallback): void;
774
795
  getSchema(options: CallOptions, callback: GetSchemaCallback): void;
796
+ /**
797
+ * Options object for requested policy version.
798
+ *
799
+ * @typedef {object} GetIamPolicyOptions
800
+ * @property {number|null} [requestedPolicyVersion] policy version requested, possible values are 0, 1 and 3,
801
+ * See {@link https://cloud.google.com/iam/docs/policies#versions} for more details
802
+ * @property {object} [gaxOptions] Request configuration options,
803
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
804
+ * for more details.
805
+ */
806
+ /**
807
+ * @callback GetIamPolicyCallback
808
+ * @param {?Error} err Request error, if any.
809
+ * @param {google.iam.v1.Policy| undefined} policy Returns policy for the give database
810
+ */
811
+ /**
812
+ * Retrieves the policy of the database.
813
+ *
814
+ * A Policy is a collection of bindings. A binding binds one or more members, or principals,
815
+ * to a single role. Principals can be user accounts, service accounts, Google groups, and
816
+ * domains (such as G Suite). A role is a named list of permissions; each role can be an IAM
817
+ * predefined role or a user-created custom role.
818
+ *
819
+ * @see {@link #getIamPolicy}
820
+ *
821
+ * @method Database#getIamPolicy
822
+ * @param {object} [options] requestedPolicyVersion and gax options(configuration options)
823
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
824
+ * for more details on gax options.
825
+ * @param {GetIamPolicyCallback} [callback] Callback function.
826
+ * @returns {Promise<Policy | undefined>}
827
+ * When resolved, contains the current policy of the database.
828
+ *
829
+ * @example
830
+ * ```
831
+ * const {Spanner} = require('@google-cloud/spanner');
832
+ * const spanner = new Spanner();
833
+ * const instance = spanner.instance('my-instance');
834
+ * const database = instance.database('my-database');
835
+ * const policy = await database.getIamPolicy();
836
+ * console.log(policy.bindings, policy.version, policy.etag, policy.auditConfigs)
837
+ * const policyWithVersion specified = await database.getIamPolicy({requestedPolicyVersion: 3});
838
+ * ```
839
+ */
840
+ getIamPolicy(options?: GetIamPolicyOptions): Promise<GetIamPolicyResponse>;
841
+ getIamPolicy(callback: GetIamPolicyCallback): void;
842
+ getIamPolicy(options: GetIamPolicyOptions, callback: GetIamPolicyCallback): void;
775
843
  /**
776
844
  * Options object for listing sessions.
777
845
  *
@@ -1068,6 +1136,67 @@ declare class Database extends common.GrpcServiceObject {
1068
1136
  getOperations(options?: GetDatabaseOperationsOptions): Promise<GetDatabaseOperationsResponse>;
1069
1137
  getOperations(callback: GetDatabaseOperationsCallback): void;
1070
1138
  getOperations(options: GetDatabaseOperationsOptions, callback: GetDatabaseOperationsCallback): void;
1139
+ /**
1140
+ * @typedef {array} GetDatabaseRolesResponse
1141
+ * @property {IDatabaseRolees[]} 0 Array of list of database roles.
1142
+ * @property {object} 1 A query object to receive more results.
1143
+ * @property {object} 2 The full API response.
1144
+ */
1145
+ /**
1146
+ * @callback GetDatabaseRolesCallback
1147
+ * @param {?Error} err Request error, if any.
1148
+ * @param {object} apiResponse The full API response.
1149
+ */
1150
+ /**
1151
+ * Gets a list of database roles
1152
+ *
1153
+ * @see {@link v1.DatabaseAdminClient#getDatabaseRoles}
1154
+ * @see [GetDatabaseRoles API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseRoles)
1155
+ *
1156
+ * @param {object} [gaxOptions] Request configuration options,
1157
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1158
+ * for more details.
1159
+ * @param {GetDatabaseRolesCallback} [callback] Callback function.
1160
+ * @returns {Promise<GetDatabaseRolesResponse>}
1161
+ *
1162
+ * @example
1163
+ * ```
1164
+ * const {Spanner} = require('@google-cloud/spanner');
1165
+ * const spanner = new Spanner();
1166
+ *
1167
+ * const instance = spanner.instance('my-instance');
1168
+ * const database = instance.database('my-database');
1169
+ *
1170
+ * database.getDatabaseRoles(function(err, roles) {
1171
+ * // `roles` is an array of `DatabaseRoles` objects.
1172
+ * });
1173
+ *
1174
+ * //-
1175
+ * // To control how many API requests are made and page through the results
1176
+ * // manually, set `autoPaginate` to `false`.
1177
+ * //-
1178
+ * function callback(err, roles, nextQuery, apiResponse) {
1179
+ * if (nextQuery) {
1180
+ * // More results exist.
1181
+ * database.getDatabaseRoles(nextQuery, callback);
1182
+ * }
1183
+ * }
1184
+ *
1185
+ * database.getInstances({
1186
+ * gaxOptions: {autoPaginate: false}
1187
+ * }, callback);
1188
+ *
1189
+ * //-
1190
+ * // If the callback is omitted, we'll return a Promise.
1191
+ * //-
1192
+ * database.getInstances().then(function(data) {
1193
+ * const roles = data[0];
1194
+ * });
1195
+ * ```
1196
+ */
1197
+ getDatabaseRoles(gaxOptions?: CallOptions): Promise<GetDatabaseRolesResponse>;
1198
+ getDatabaseRoles(callback: GetDatabaseRolesCallback): void;
1199
+ getDatabaseRoles(gaxOptions: CallOptions, callback: GetDatabaseRolesCallback): void;
1071
1200
  /**
1072
1201
  * Make an API request, first assuring an active session is used.
1073
1202
  *
@@ -1583,6 +1712,57 @@ declare class Database extends common.GrpcServiceObject {
1583
1712
  * const table = database.table('Singers');
1584
1713
  * ```
1585
1714
  */
1715
+ /**
1716
+ * @callback SetIamPolicyCallback
1717
+ * @param {?Error} err Request error, if any.
1718
+ * @param {google.iam.v1.Policy| undefined} policy Returns policy for the give database
1719
+ */
1720
+ /**
1721
+ * Sets the policy for the database.
1722
+ *
1723
+ * A Policy is a collection of bindings. A binding binds one or more members, or principals,
1724
+ * to a single role. Principals can be user accounts, service accounts, Google groups, and
1725
+ * domains (such as G Suite). A role is a named list of permissions; each role can be an IAM
1726
+ * predefined role or a user-created custom role.
1727
+ *
1728
+ * @see {@link #setIamPolicy}
1729
+ *
1730
+ * @method Database#setIamPolicy
1731
+ * @param {object} [policy] requestedPolicyVersion and gax options(configuration options)
1732
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
1733
+ * for more details on gax options.
1734
+ * @param {object} [options] Requested configuration options,
1735
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
1736
+ * for more details on Call Options.
1737
+ * @param {SetIamPolicyCallback} [callback] Callback function.
1738
+ * @returns {Promise<Policy | undefined>}
1739
+ * When resolved, contains the current policy of the database.
1740
+ *
1741
+ * @example
1742
+ * ```
1743
+ * const {Spanner} = require('@google-cloud/spanner');
1744
+ * const spanner = new Spanner();
1745
+ * const instance = spanner.instance('my-instance');
1746
+ * const database = instance.database('my-database');
1747
+ * const binding = {
1748
+ * role: 'roles/spanner.fineGrainedAccessUser',
1749
+ * members: ['user:asthamohta@google.com'],
1750
+ * condition: {
1751
+ * title: 'new condition',
1752
+ * expression: 'resource.name.endsWith("/databaseRoles/parent")',
1753
+ * },
1754
+ * };
1755
+ * const policy = {
1756
+ * bindings: [newBinding],
1757
+ * version: 3,
1758
+ *};
1759
+ * const policy = await database.setIamPolicy({policy: policy});
1760
+ * ```
1761
+ */
1762
+ setIamPolicy(policy: SetIamPolicyRequest): Promise<SetIamPolicyResponse>;
1763
+ setIamPolicy(policy: SetIamPolicyRequest, options?: CallOptions): Promise<SetIamPolicyResponse>;
1764
+ setIamPolicy(policy: SetIamPolicyRequest, callback: SetIamPolicyCallback): void;
1765
+ setIamPolicy(policy: SetIamPolicyRequest, options: CallOptions, callback: SetIamPolicyCallback): void;
1586
1766
  table(name: string): Table;
1587
1767
  /**
1588
1768
  * Update the schema of the database by creating/altering/dropping tables,