@google-cloud/spanner 7.17.0 → 7.18.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +1 -1
  3. package/build/protos/google/spanner/admin/database/v1/backup.proto +0 -757
  4. package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +0 -230
  5. package/build/protos/google/spanner/admin/database/v1/common.proto +0 -132
  6. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +0 -1209
  7. package/build/protos/google/spanner/admin/instance/v1/common.proto +0 -63
  8. package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +0 -1983
  9. package/build/protos/google/spanner/executor/v1/cloud_executor.proto +0 -1520
  10. package/build/protos/google/spanner/v1/commit_response.proto +0 -59
  11. package/build/protos/google/spanner/v1/keys.proto +0 -163
  12. package/build/protos/google/spanner/v1/mutation.proto +0 -107
  13. package/build/protos/google/spanner/v1/query_plan.proto +0 -128
  14. package/build/protos/google/spanner/v1/result_set.proto +0 -237
  15. package/build/protos/google/spanner/v1/spanner.proto +0 -1389
  16. package/build/protos/google/spanner/v1/transaction.proto +0 -575
  17. package/build/protos/google/spanner/v1/type.proto +0 -210
  18. package/build/protos/protos.d.ts +0 -38999
  19. package/build/protos/protos.js +0 -99538
  20. package/build/protos/protos.json +0 -10182
  21. package/build/src/backup.d.ts +0 -349
  22. package/build/src/backup.js +0 -246
  23. package/build/src/batch-transaction.d.ts +0 -247
  24. package/build/src/batch-transaction.js +0 -384
  25. package/build/src/codec.d.ts +0 -362
  26. package/build/src/codec.js +0 -791
  27. package/build/src/common-grpc/service-object.d.ts +0 -80
  28. package/build/src/common-grpc/service-object.js +0 -101
  29. package/build/src/common-grpc/service.d.ts +0 -445
  30. package/build/src/common-grpc/service.js +0 -826
  31. package/build/src/common.d.ts +0 -66
  32. package/build/src/common.js +0 -54
  33. package/build/src/database.d.ts +0 -2104
  34. package/build/src/database.js +0 -1655
  35. package/build/src/extra_proto_list.json +0 -1
  36. package/build/src/helper.d.ts +0 -45
  37. package/build/src/helper.js +0 -71
  38. package/build/src/index.d.ts +0 -1195
  39. package/build/src/index.js +0 -1060
  40. package/build/src/instance-config.d.ts +0 -295
  41. package/build/src/instance-config.js +0 -216
  42. package/build/src/instance.d.ts +0 -833
  43. package/build/src/instance.js +0 -781
  44. package/build/src/instrument.d.ts +0 -87
  45. package/build/src/instrument.js +0 -217
  46. package/build/src/multiplexed-session.d.ts +0 -136
  47. package/build/src/multiplexed-session.js +0 -197
  48. package/build/src/partial-result-stream.d.ts +0 -253
  49. package/build/src/partial-result-stream.js +0 -400
  50. package/build/src/session-factory.d.ts +0 -101
  51. package/build/src/session-factory.js +0 -93
  52. package/build/src/session-pool.d.ts +0 -471
  53. package/build/src/session-pool.js +0 -754
  54. package/build/src/session.d.ts +0 -259
  55. package/build/src/session.js +0 -348
  56. package/build/src/spanner_grpc_config.json +0 -92
  57. package/build/src/table.d.ts +0 -831
  58. package/build/src/table.js +0 -277
  59. package/build/src/transaction-runner.d.ts +0 -185
  60. package/build/src/transaction-runner.js +0 -282
  61. package/build/src/transaction.d.ts +0 -1691
  62. package/build/src/transaction.js +0 -2004
  63. package/build/src/v1/database_admin_client.d.ts +0 -2301
  64. package/build/src/v1/database_admin_client.js +0 -2286
  65. package/build/src/v1/database_admin_client_config.json +0 -160
  66. package/build/src/v1/database_admin_proto_list.json +0 -6
  67. package/build/src/v1/gapic_metadata.json +0 -27
  68. package/build/src/v1/index.d.ts +0 -4
  69. package/build/src/v1/index.js +0 -29
  70. package/build/src/v1/instance_admin_client.d.ts +0 -1982
  71. package/build/src/v1/instance_admin_client.js +0 -1766
  72. package/build/src/v1/instance_admin_client_config.json +0 -129
  73. package/build/src/v1/instance_admin_proto_list.json +0 -4
  74. package/build/src/v1/spanner_client.d.ts +0 -1250
  75. package/build/src/v1/spanner_client.js +0 -1086
  76. package/build/src/v1/spanner_client_config.json +0 -119
  77. package/build/src/v1/spanner_executor_proxy_client.d.ts +0 -418
  78. package/build/src/v1/spanner_executor_proxy_client.js +0 -706
  79. package/build/src/v1/spanner_executor_proxy_client_config.json +0 -30
  80. package/build/src/v1/spanner_executor_proxy_proto_list.json +0 -14
  81. package/build/src/v1/spanner_proto_list.json +0 -10
@@ -1,295 +0,0 @@
1
- /**
2
- * Copyright 2022 Google LLC
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
- declare const common: any;
16
- import { google as instanceAdmin } from '../protos/protos';
17
- import { Operation as GaxOperation } from 'google-gax/build/src/longRunningCalls/longrunning';
18
- import { LongRunningCallback, RequestCallback, ResourceCallback, NormalCallback } from './common';
19
- import { GetInstanceConfigCallback, GetInstanceConfigOptions, GetInstanceConfigResponse, RequestConfig, Spanner } from './index';
20
- import { CallOptions } from 'google-gax';
21
- export type IOperation = instanceAdmin.longrunning.IOperation;
22
- export type CreateInstanceConfigCallback = LongRunningCallback<InstanceConfig>;
23
- export type SetInstanceConfigMetadataCallback = ResourceCallback<GaxOperation, IOperation>;
24
- export type DeleteInstanceConfigCallback = NormalCallback<instanceAdmin.protobuf.IEmpty>;
25
- export type ExistsInstanceConfigCallback = NormalCallback<boolean>;
26
- export type CreateInstanceConfigResponse = [
27
- InstanceConfig,
28
- GaxOperation,
29
- IOperation
30
- ];
31
- export type SetInstanceConfigMetadataResponse = [GaxOperation, IOperation];
32
- export type DeleteInstanceConfigResponse = [instanceAdmin.protobuf.IEmpty];
33
- export type ExistsInstanceConfigResponse = boolean;
34
- export type IInstanceConfig = instanceAdmin.spanner.admin.instance.v1.IInstanceConfig;
35
- interface InstanceConfigRequest {
36
- (config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
37
- <T>(config: RequestConfig, callback: RequestCallback<T>): void;
38
- <T, R>(config: RequestConfig, callback: RequestCallback<T, R>): void;
39
- }
40
- export interface SetInstanceConfigMetadataRequest {
41
- instanceConfig: IInstanceConfig;
42
- validateOnly?: boolean;
43
- gaxOpts?: CallOptions;
44
- }
45
- interface DeleteInstanceConfigRequest {
46
- etag?: string;
47
- validateOnly?: boolean;
48
- gaxOpts?: CallOptions;
49
- }
50
- /**
51
- * The {@link InstanceConfig} class represents a possible configuration for a
52
- * Cloud Spanner instance.
53
- *
54
- * Create an `InstanceConfig` object to interact with a Cloud Spanner instance
55
- * config.
56
- *
57
- * @class
58
- *
59
- * @param {Spanner} spanner {@link Spanner} instance.
60
- * @param {string} name Name of the instance config.
61
- *
62
- * @example
63
- * ```
64
- * const {Spanner} = require('@google-cloud/spanner');
65
- * const spanner = new Spanner();
66
- * const instance = spanner.instanceConfig('my-instance-config');
67
- * ```
68
- */
69
- declare class InstanceConfig extends common.GrpcServiceObject {
70
- static [x: string]: any;
71
- formattedName_: string;
72
- request: InstanceConfigRequest;
73
- metadata?: IInstanceConfig;
74
- resourceHeader_: {
75
- [k: string]: string;
76
- };
77
- constructor(spanner: Spanner, name: string);
78
- /**
79
- * Gets the metadata from the backend for this InstanceConfig.
80
- */
81
- /**
82
- * @typedef {array} GetInstanceConfigResponse
83
- * @property {object[]} 0 The metadata of the instance config.
84
- * @property {string} 0.name The unique identifier for the instance config.
85
- * @property {string} 0.displayName The name of the instance config as it
86
- * appears in UIs.
87
- * @property {google.spanner.admin.instance.v1.IReplicaInfo[]} 0.replicas The replicas used by
88
- * this instance config.
89
- * @property {string[]} 0.leaderOptions The possible leader options for this instance config.
90
- */
91
- /**
92
- * @callback GetInstanceConfigCallback
93
- * @param {?Error} err Request error, if any.
94
- * @param {object} instanceConfig The metadata of the instance config.
95
- * @param {string} instanceConfig.name The unique identifier for the instance
96
- * config.
97
- * @param {string} instanceConfig.displayName The name of the instance config
98
- * as it appears in UIs.
99
- * @param {google.spanner.admin.instance.v1.IReplicaInfo[]} instanceConfig.replicas The replicas used by
100
- * this instance config.
101
- * @param {string[]} 0.leaderOptions The possible leader options for this instance config.
102
- */
103
- /**
104
- * Gets the metadata from the backend for this InstanceConfig.
105
- *
106
- * Wrapper around {@link v1.InstanceAdminClient#getInstanceConfig}.
107
- *
108
- * @see {@link v1.InstanceAdminClient#getInstanceConfig}
109
- * @see [GetInstanceConfig API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig)
110
- *
111
- * @param {GetInstanceConfigCallback} [callback] Callback function.
112
- * @returns {Promise<GetInstanceConfigResponse>}
113
- *
114
- * @example
115
- * ```
116
- * const {Spanner} = require('@google-cloud/spanner');
117
- * const spanner = new Spanner();
118
- *
119
- * const instanceConfig = spanner.instanceConfig('custom-my-instance-config');
120
- *
121
- * instanceConfig.get(function(err, instanceConfig) {
122
- * // `instanceConfig` is an instance configuration descriptor.
123
- * });
124
- *
125
- * //-
126
- * // If the callback is omitted, we'll return a Promise.
127
- * //-
128
- * instanceConfig.get().then(function(data) {
129
- * const instanceConfig = data[0];
130
- * });
131
- * ```
132
- */
133
- get(options?: GetInstanceConfigOptions): Promise<GetInstanceConfigResponse>;
134
- get(callback: GetInstanceConfigCallback): void;
135
- get(options: GetInstanceConfigOptions, callback: GetInstanceConfigCallback): void;
136
- /**
137
- * Update the metadata for this instance config. Note that this method follows
138
- * PATCH semantics, so previously-configured settings will persist.
139
- * This function can only be called for deleting user managed instance
140
- * configs.
141
- *
142
- * Wrapper around {@link v1.InstanceAdminClient#updateInstanceConfig}.
143
- *
144
- * @see {@link v1.InstanceAdminClient#updateInstanceConfig}
145
- * @see [UpdateInstanceConfig API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig)
146
- *
147
- * @param {object} metadata The metadata you wish to set.
148
- * @param {object} [gaxOptions] Request configuration options,
149
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
150
- * for more details.
151
- * @param {SetInstanceConfigMetadataCallback} [callback] Callback function.
152
- * @returns {Promise<LongRunningOperationResponse>}
153
- *
154
- * @example
155
- * ```
156
- * const {Spanner} = require('@google-cloud/spanner');
157
- * const spanner = new Spanner();
158
- *
159
- * const instanceConfig = spanner.instanceConfig('custom-my-instance-config');
160
- *
161
- * const metadata = {
162
- * instanceConfig: {
163
- * displayName: 'My Instance Config'
164
- * }
165
- * };
166
- *
167
- * instanceConfig.setMetadata(metadata, function(err, operation, apiResponse) {
168
- * if (err) {
169
- * // Error handling omitted.
170
- * }
171
- *
172
- * operation
173
- * .on('error', function(err) {})
174
- * .on('complete', function() {
175
- * // Metadata updated successfully.
176
- * });
177
- * });
178
- *
179
- * //-
180
- * // If the callback is omitted, we'll return a Promise.
181
- * //-
182
- * instanceConfig.setMetadata(metadata).then(function(data) {
183
- * const operation = data[0];
184
- * const apiResponse = data[1];
185
- * });
186
- * ```
187
- */
188
- setMetadata(config: SetInstanceConfigMetadataRequest): Promise<SetInstanceConfigMetadataResponse>;
189
- setMetadata(config: SetInstanceConfigMetadataRequest, callback: SetInstanceConfigMetadataCallback): void;
190
- /**
191
- * @typedef {array} DeleteInstanceConfigResponse
192
- * @property {object} 0 The full API response.
193
- */
194
- /**
195
- * @callback DeleteInstanceConfigCallback
196
- * @param {?Error} err Request error, if any.
197
- * @param {object} apiResponse The full API response.
198
- */
199
- /**
200
- * Delete the instance config. This function can only be called for deleting
201
- * user managed instance configs.
202
- *
203
- * Wrapper around {@link v1.InstanceAdminClient#deleteInstanceConfig}.
204
- *
205
- * @see {@link v1.InstanceAdminClient#deleteInstanceConfig}
206
- * @see [DeleteInstanceConfig API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstanceConfig)
207
- *
208
- * @param {object} [gaxOptions] Request configuration options,
209
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
210
- * for more details.
211
- * @param {DeleteInstanceConfigCallback} [callback] Callback function.
212
- * @returns {Promise<DeleteInstanceConfigResponse>}
213
- *
214
- * @example
215
- * ```
216
- * const {Spanner} = require('@google-cloud/spanner');
217
- * const spanner = new Spanner();
218
- *
219
- * const instanceConfig = spanner.instanceConfig('custom-my-instance-config');
220
- *
221
- * instanceConfig.delete(function(err, apiResponse) {
222
- * if (err) {
223
- * // Error handling omitted.
224
- * }
225
- *
226
- * // Instance config was deleted successfully.
227
- * });
228
- *
229
- * //-
230
- * // If the callback is omitted, we'll return a Promise.
231
- * //-
232
- * instanceConfig.delete().then(function(data) {
233
- * const apiResponse = data[0];
234
- * });
235
- * ```
236
- */
237
- delete(config?: DeleteInstanceConfigRequest): Promise<DeleteInstanceConfigResponse>;
238
- delete(callback: DeleteInstanceConfigCallback): void;
239
- delete(config: DeleteInstanceConfigRequest, callback: DeleteInstanceConfigCallback): void;
240
- /**
241
- * @typedef {array} ExistsInstanceConfigResponse
242
- * @property {boolean} 0 Whether the {@link InstanceConfig} exists.
243
- */
244
- /**
245
- * @callback ExistsInstanceConfigCallback
246
- * @param {?Error} err Request error, if any.
247
- * @param {boolean} exists Whether the {@link InstanceConfig} exists.
248
- */
249
- /**
250
- * Check if an instance config exists.
251
- *
252
- * @method InstanceConfig#exists
253
- * @param {object} [gaxOptions] Request configuration options,
254
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
255
- * for more details.
256
- * @param {ExistsInstanceConfigCallback} [callback] Callback function.
257
- * @returns {Promise<ExistsInstanceConfigResponse>} When resolved, contains
258
- * true if the instance config exists and false if it does not exist.
259
- *
260
- * @example
261
- * ```
262
- * const {Spanner} = require('@google-cloud/spanner');
263
- * const spanner = new Spanner();
264
- *
265
- * const instanceConfig = spanner.instanceConfig('custom-my-instance-config');
266
- *
267
- * const exists = await instanceConfig.exists();
268
- * console.log(`Does instance config exist? ${exists}`);
269
- * ```
270
- */
271
- exists(): Promise<ExistsInstanceConfigResponse>;
272
- exists(callback: ExistsInstanceConfigCallback): void;
273
- /**
274
- * Format the instance config name to include the project ID.
275
- *
276
- * @private
277
- *
278
- * @param {string} projectId The project ID.
279
- * @param {string} name The instance config name.
280
- * @returns {string}
281
- *
282
- * @example
283
- * ```
284
- * InstanceConfig.formatName_('grape-spaceship-123', 'my-instance-config');
285
- * // 'projects/grape-spaceship-123/instanceConfigs/my-instance-config'
286
- * ```
287
- */
288
- static formatName_(projectId: string, name: string): string;
289
- }
290
- /**
291
- * Reference to the {@link InstanceConfig} class.
292
- * @name module:@google-cloud/spanner.InstanceConfig
293
- * @see InstanceConfig
294
- */
295
- export { InstanceConfig };
@@ -1,216 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright 2022 Google LLC
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.InstanceConfig = void 0;
18
- const common = require('./common-grpc/service-object');
19
- const snakeCase = require("lodash.snakecase");
20
- const common_1 = require("./common");
21
- const promisify_1 = require("@google-cloud/promisify");
22
- const google_gax_1 = require("google-gax");
23
- const extend = require("extend");
24
- /**
25
- * The {@link InstanceConfig} class represents a possible configuration for a
26
- * Cloud Spanner instance.
27
- *
28
- * Create an `InstanceConfig` object to interact with a Cloud Spanner instance
29
- * config.
30
- *
31
- * @class
32
- *
33
- * @param {Spanner} spanner {@link Spanner} instance.
34
- * @param {string} name Name of the instance config.
35
- *
36
- * @example
37
- * ```
38
- * const {Spanner} = require('@google-cloud/spanner');
39
- * const spanner = new Spanner();
40
- * const instance = spanner.instanceConfig('my-instance-config');
41
- * ```
42
- */
43
- class InstanceConfig extends common.GrpcServiceObject {
44
- constructor(spanner, name) {
45
- const formattedName_ = InstanceConfig.formatName_(spanner.projectId, name);
46
- const methods = {
47
- /**
48
- * Create an instance config.
49
- *
50
- * Wrapper around {@link v1.InstanceAdminClient#createInstanceConfig}.
51
- *
52
- * @see {@link v1.InstanceAdminClient#createInstanceConfig}
53
- * @see [CreateInstanceConfig API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig)
54
- *
55
- * @method InstanceConfig#create
56
- * @param {CreateInstanceConfigRequest} config Configuration object.
57
- * @param {CreateInstanceConfigCallback} [callback] Callback function.
58
- * @returns {Promise<CreateInstanceConfigResponse>}
59
- *
60
- * @example
61
- * ```
62
- * const {Spanner} = require('@google-cloud/spanner');
63
- * const spanner = new Spanner();
64
- *
65
- * const instanceConfig =
66
- * spanner.instanceConfig('custom-my-instance-config');
67
- *
68
- * instanceConfig.create(function(err, instance, operation, apiResponse) {
69
- * if (err) {
70
- * // Error handling omitted.
71
- * }
72
- *
73
- * operation
74
- * .on('error', function(err) {})
75
- * .on('complete', function() {
76
- * // Instance config created successfully.
77
- * });
78
- * });
79
- *
80
- * //-
81
- * // If the callback is omitted, we'll return a Promise.
82
- * //-
83
- * instanceConfig.create()
84
- * .then(function(data) {
85
- * const operation = data[0];
86
- * const apiResponse = data[1];
87
- *
88
- * return operation.promise();
89
- * })
90
- * .then(function() {
91
- * // Instance config created successfully.
92
- * });
93
- * ```
94
- */
95
- create: true,
96
- };
97
- super({
98
- parent: spanner,
99
- id: name,
100
- methods,
101
- createMethod(_, options, callback) {
102
- spanner.createInstanceConfig(formattedName_, options, callback);
103
- },
104
- });
105
- this.formattedName_ = formattedName_;
106
- this.request = spanner.request.bind(spanner);
107
- this.resourceHeader_ = {
108
- [common_1.CLOUD_RESOURCE_HEADER]: this.formattedName_,
109
- };
110
- }
111
- get(optionsOrCallback, cb) {
112
- const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
113
- const options = typeof optionsOrCallback === 'object'
114
- ? optionsOrCallback
115
- : {};
116
- this.parent.getInstanceConfig(this.id, options, callback);
117
- }
118
- setMetadata(config, callback) {
119
- const reqOpts = {
120
- instanceConfig: extend({
121
- name: this.formattedName_,
122
- }, config.instanceConfig),
123
- updateMask: {
124
- paths: Object.keys(config.instanceConfig).map(snakeCase),
125
- },
126
- validateOnly: config.validateOnly,
127
- };
128
- // validateOnly need not be passed in if it is null or undefined.
129
- if (reqOpts.validateOnly === null || reqOpts.validateOnly === undefined)
130
- delete reqOpts.validateOnly;
131
- return this.request({
132
- client: 'InstanceAdminClient',
133
- method: 'updateInstanceConfig',
134
- reqOpts,
135
- gaxOpts: config.gaxOpts === null || config.gaxOpts === undefined
136
- ? {}
137
- : config.gaxOpts,
138
- headers: this.resourceHeader_,
139
- }, callback);
140
- }
141
- delete(optionsOrCallback, cb) {
142
- const config = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
143
- const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
144
- const reqOpts = {
145
- name: this.formattedName_,
146
- etag: config.etag,
147
- validateOnly: config.validateOnly,
148
- };
149
- // etag/validateOnly need not be passed in if null or undefined.
150
- if (reqOpts.etag === null || reqOpts.etag === undefined)
151
- delete reqOpts.etag;
152
- if (reqOpts.validateOnly === null || reqOpts.etag === undefined)
153
- delete reqOpts.validateOnly;
154
- this.request({
155
- client: 'InstanceAdminClient',
156
- method: 'deleteInstanceConfig',
157
- reqOpts,
158
- gaxOpts: config.gaxOpts === null || config.gaxOpts === undefined
159
- ? {}
160
- : config.gaxOpts,
161
- headers: this.resourceHeader_,
162
- }, (err, resp) => {
163
- if (!err) {
164
- this.parent.instanceConfigs_.delete(this.id);
165
- }
166
- callback(err, resp);
167
- });
168
- }
169
- async exists() {
170
- try {
171
- // Attempt to read metadata to determine whether instance config exists
172
- await this.get();
173
- // Found, therefore it exists
174
- return true;
175
- }
176
- catch (err) {
177
- if (err.code === google_gax_1.grpc.status.NOT_FOUND) {
178
- return false;
179
- }
180
- // Some other error occurred, rethrow
181
- throw err;
182
- }
183
- }
184
- /**
185
- * Format the instance config name to include the project ID.
186
- *
187
- * @private
188
- *
189
- * @param {string} projectId The project ID.
190
- * @param {string} name The instance config name.
191
- * @returns {string}
192
- *
193
- * @example
194
- * ```
195
- * InstanceConfig.formatName_('grape-spaceship-123', 'my-instance-config');
196
- * // 'projects/grape-spaceship-123/instanceConfigs/my-instance-config'
197
- * ```
198
- */
199
- static formatName_(projectId, name) {
200
- if (name.indexOf('/') > -1) {
201
- return name;
202
- }
203
- const instanceConfigName = name.split('/').pop();
204
- return 'projects/' + projectId + '/instanceConfigs/' + instanceConfigName;
205
- }
206
- }
207
- exports.InstanceConfig = InstanceConfig;
208
- /*! Developer Documentation
209
- *
210
- * All async methods (except for streams) will return a Promise in the event
211
- * that a callback is omitted.
212
- */
213
- (0, promisify_1.promisifyAll)(InstanceConfig, {
214
- exclude: ['exists'],
215
- });
216
- //# sourceMappingURL=instance-config.js.map