diff --git a/CHANGELOG.md b/CHANGELOG.md index 91f8668a4..9c047e8fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ [1]: https://www.npmjs.com/package/nodejs-spanner?activeTab=versions +## [6.2.0](https://github.com/googleapis/nodejs-spanner/compare/v6.1.4...v6.2.0) (2022-09-16) + + +### Features + +* Add custom instance config operations ([#1712](https://github.com/googleapis/nodejs-spanner/issues/1712)) ([4b7716b](https://github.com/googleapis/nodejs-spanner/commit/4b7716be5409698e21bb79edec5cdf1019047de8)) + + +### Bug Fixes + +* Allow passing gax instance to client constructor ([#1698](https://github.com/googleapis/nodejs-spanner/issues/1698)) ([588c1a2](https://github.com/googleapis/nodejs-spanner/commit/588c1a2e0c449cfcb86cac73da32dd5794ee2baa)) +* **deps:** Use grpc-gcp v1.0.0 ([#1710](https://github.com/googleapis/nodejs-spanner/issues/1710)) ([12eab9d](https://github.com/googleapis/nodejs-spanner/commit/12eab9d628b72b5a7fc88f3d5e932b7a4d70dce2)) +* Move runtime dependencies from dev dependencies to dependencies ([#1704](https://github.com/googleapis/nodejs-spanner/issues/1704)) ([b2c1c0f](https://github.com/googleapis/nodejs-spanner/commit/b2c1c0f93653af6cc7bd9893ca14394f2a631b68)) +* Preserve default values in x-goog-request-params header ([#1711](https://github.com/googleapis/nodejs-spanner/issues/1711)) ([f1ae513](https://github.com/googleapis/nodejs-spanner/commit/f1ae51301d4ea9b0ed1ad4d4762c249fef9f8d08)) + ## [6.1.4](https://github.com/googleapis/nodejs-spanner/compare/v6.1.3...v6.1.4) (2022-09-06) diff --git a/package.json b/package.json index 3786acfe1..d561339d7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/spanner", "description": "Cloud Spanner Client Library for Node.js", - "version": "6.1.4", + "version": "6.2.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { @@ -54,28 +54,31 @@ "@google-cloud/precise-date": "^2.0.0", "@google-cloud/projectify": "^3.0.0", "@google-cloud/promisify": "^3.0.0", + "@grpc/proto-loader": "^0.7.0", "@types/big.js": "^6.0.0", "@types/stack-trace": "0.0.29", "arrify": "^2.0.0", "big.js": "^6.0.0", "checkpoint-stream": "^0.1.1", + "duplexify": "^4.1.1", "events-intercept": "^2.0.0", "extend": "^3.0.2", "google-auth-library": "^8.0.2", "google-gax": "^3.0.1", - "grpc-gcp": "^0.4.0", + "grpc-gcp": "^1.0.0", "is": "^3.2.1", "lodash.snakecase": "^4.1.1", "merge-stream": "^2.0.0", "p-queue": "^6.0.2", "protobufjs": "^7.0.0", + "retry-request": "^5.0.0", "split-array-stream": "^2.0.0", "stack-trace": "0.0.10", "stream-events": "^1.0.4", + "teeny-request": "^8.0.0", "through2": "^4.0.0" }, "devDependencies": { - "@grpc/proto-loader": "^0.7.0", "@types/concat-stream": "^2.0.0", "@types/extend": "^3.0.0", "@types/is": "0.0.21", @@ -94,7 +97,6 @@ "codecov": "^3.0.2", "concat-stream": "^2.0.0", "dedent": "^0.7.0", - "duplexify": "^4.1.1", "execa": "^5.0.0", "gts": "^3.1.0", "jsdoc": "^3.6.2", @@ -107,14 +109,12 @@ "ncp": "^2.0.0", "p-limit": "^3.0.1", "proxyquire": "^2.0.1", - "retry-request": "^5.0.0", "sinon": "^14.0.0", "stats-lite": "^2.1.1", - "teeny-request": "^8.0.0", "time-span": "^4.0.0", "tmp": "^0.2.0", "typescript": "^4.6.4", - "uuid": "^8.0.0", + "uuid": "^9.0.0", "yargs": "^17.0.0" } } diff --git a/protos/google/spanner/admin/instance/v1/common.proto b/protos/google/spanner/admin/instance/v1/common.proto new file mode 100644 index 000000000..e93b33476 --- /dev/null +++ b/protos/google/spanner/admin/instance/v1/common.proto @@ -0,0 +1,42 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.spanner.admin.instance.v1; + +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Instance.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/admin/instance/v1;instance"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.spanner.admin.instance.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Instance\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Instance::V1"; + +// Encapsulates progress related information for a Cloud Spanner long +// running instance operations. +message OperationProgress { + // Percent completion of the operation. + // Values are between 0 and 100 inclusive. + int32 progress_percent = 1; + + // Time the request was received. + google.protobuf.Timestamp start_time = 2; + + // If set, the time at which this operation failed or was completed + // successfully. + google.protobuf.Timestamp end_time = 3; +} diff --git a/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto b/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto index 3bde51d99..85b041134 100644 --- a/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +++ b/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -26,6 +26,7 @@ import "google/longrunning/operations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; +import "google/spanner/admin/instance/v1/common.proto"; option csharp_namespace = "Google.Cloud.Spanner.Admin.Instance.V1"; option go_package = "google.golang.org/genproto/googleapis/spanner/admin/instance/v1;instance"; @@ -63,7 +64,8 @@ service InstanceAdmin { "https://www.googleapis.com/auth/spanner.admin"; // Lists the supported instance configurations for a given project. - rpc ListInstanceConfigs(ListInstanceConfigsRequest) returns (ListInstanceConfigsResponse) { + rpc ListInstanceConfigs(ListInstanceConfigsRequest) + returns (ListInstanceConfigsResponse) { option (google.api.http) = { get: "/v1/{parent=projects/*}/instanceConfigs" }; @@ -78,6 +80,153 @@ service InstanceAdmin { option (google.api.method_signature) = "name"; } + // Creates an instance config and begins preparing it to be used. The + // returned [long-running operation][google.longrunning.Operation] + // can be used to track the progress of preparing the new + // instance config. The instance config name is assigned by the caller. If the + // named instance config already exists, `CreateInstanceConfig` returns + // `ALREADY_EXISTS`. + // + // Immediately after the request returns: + // + // * The instance config is readable via the API, with all requested + // attributes. The instance config's + // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + // field is set to true. Its state is `CREATING`. + // + // While the operation is pending: + // + // * Cancelling the operation renders the instance config immediately + // unreadable via the API. + // * Except for deleting the creating resource, all other attempts to modify + // the instance config are rejected. + // + // Upon completion of the returned operation: + // + // * Instances can be created using the instance configuration. + // * The instance config's + // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + // field becomes false. Its state becomes `READY`. + // + // The returned [long-running operation][google.longrunning.Operation] will + // have a name of the format + // `/operations/` and can be used to track + // creation of the instance config. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + // The [response][google.longrunning.Operation.response] field type is + // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + // successful. + // + // Authorization requires `spanner.instanceConfigs.create` permission on + // the resource + // [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]. + rpc CreateInstanceConfig(CreateInstanceConfigRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/instanceConfigs" + body: "*" + }; + option (google.api.method_signature) = + "parent,instance_config,instance_config_id"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.instance.v1.InstanceConfig" + metadata_type: "google.spanner.admin.instance.v1.CreateInstanceConfigMetadata" + }; + } + + // Updates an instance config. The returned + // [long-running operation][google.longrunning.Operation] can be used to track + // the progress of updating the instance. If the named instance config does + // not exist, returns `NOT_FOUND`. + // + // Only user managed configurations can be updated. + // + // Immediately after the request returns: + // + // * The instance config's + // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + // field is set to true. + // + // While the operation is pending: + // + // * Cancelling the operation sets its metadata's + // [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time]. + // The operation is guaranteed to succeed at undoing all changes, after + // which point it terminates with a `CANCELLED` status. + // * All other attempts to modify the instance config are rejected. + // * Reading the instance config via the API continues to give the + // pre-request values. + // + // Upon completion of the returned operation: + // + // * Creating instances using the instance configuration uses the new + // values. + // * The instance config's new values are readable via the API. + // * The instance config's + // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + // field becomes false. + // + // The returned [long-running operation][google.longrunning.Operation] will + // have a name of the format + // `/operations/` and can be used to track + // the instance config modification. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]. + // The [response][google.longrunning.Operation.response] field type is + // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + // successful. + // + // Authorization requires `spanner.instanceConfigs.update` permission on + // the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + rpc UpdateInstanceConfig(UpdateInstanceConfigRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{instance_config.name=projects/*/instanceConfigs/*}" + body: "*" + }; + option (google.api.method_signature) = "instance_config,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.instance.v1.InstanceConfig" + metadata_type: "google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata" + }; + } + + // Deletes the instance config. Deletion is only allowed when no + // instances are using the configuration. If any instances are using + // the config, returns `FAILED_PRECONDITION`. + // + // Only user managed configurations can be deleted. + // + // Authorization requires `spanner.instanceConfigs.delete` permission on + // the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + rpc DeleteInstanceConfig(DeleteInstanceConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/instanceConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the user-managed instance config [long-running + // operations][google.longrunning.Operation] in the given project. An instance + // config operation has a name of the form + // `projects//instanceConfigs//operations/`. + // The long-running operation + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. Operations returned + // include those that have completed/failed/canceled within the last 7 days, + // and pending operations. Operations returned are ordered by + // `operation.metadata.value.start_time` in descending order starting + // from the most recently started operation. + rpc ListInstanceConfigOperations(ListInstanceConfigOperationsRequest) + returns (ListInstanceConfigOperationsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/instanceConfigOperations" + }; + option (google.api.method_signature) = "parent"; + } + // Lists all instances in the given project. rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { option (google.api.http) = { @@ -128,7 +277,8 @@ service InstanceAdmin { // [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. // The [response][google.longrunning.Operation.response] field type is // [Instance][google.spanner.admin.instance.v1.Instance], if successful. - rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) { + rpc CreateInstance(CreateInstanceRequest) + returns (google.longrunning.Operation) { option (google.api.http) = { post: "/v1/{parent=projects/*}/instances" body: "*" @@ -154,9 +304,9 @@ service InstanceAdmin { // Until completion of the returned operation: // // * Cancelling the operation sets its metadata's - // [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - // restoring resources to their pre-request values. The operation - // is guaranteed to succeed at undoing all resource changes, + // [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], + // and begins restoring resources to their pre-request values. The + // operation is guaranteed to succeed at undoing all resource changes, // after which point it terminates with a `CANCELLED` status. // * All other attempts to modify the instance are rejected. // * Reading the instance via the API continues to give the pre-request @@ -180,7 +330,8 @@ service InstanceAdmin { // // Authorization requires `spanner.instances.update` permission on // the resource [name][google.spanner.admin.instance.v1.Instance.name]. - rpc UpdateInstance(UpdateInstanceRequest) returns (google.longrunning.Operation) { + rpc UpdateInstance(UpdateInstanceRequest) + returns (google.longrunning.Operation) { option (google.api.http) = { patch: "/v1/{instance.name=projects/*/instances/*}" body: "*" @@ -215,7 +366,8 @@ service InstanceAdmin { // // Authorization requires `spanner.instances.setIamPolicy` on // [resource][google.iam.v1.SetIamPolicyRequest.resource]. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { option (google.api.http) = { post: "/v1/{resource=projects/*/instances/*}:setIamPolicy" body: "*" @@ -228,7 +380,8 @@ service InstanceAdmin { // // Authorization requires `spanner.instances.getIamPolicy` on // [resource][google.iam.v1.GetIamPolicyRequest.resource]. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { option (google.api.http) = { post: "/v1/{resource=projects/*/instances/*}:getIamPolicy" body: "*" @@ -242,7 +395,8 @@ service InstanceAdmin { // result in a NOT_FOUND error if the user has `spanner.instances.list` // permission on the containing Google Cloud Project. Otherwise returns an // empty set of permissions. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { option (google.api.http) = { post: "/v1/{resource=projects/*/instances/*}:testIamPermissions" body: "*" @@ -307,6 +461,31 @@ message InstanceConfig { pattern: "projects/{project}/instanceConfigs/{instance_config}" }; + // The type of this configuration. + enum Type { + // Unspecified. + TYPE_UNSPECIFIED = 0; + + // Google managed configuration. + GOOGLE_MANAGED = 1; + + // User managed configuration. + USER_MANAGED = 2; + } + + // Indicates the current state of the instance config. + enum State { + // Not specified. + STATE_UNSPECIFIED = 0; + + // The instance config is still being created. + CREATING = 1; + + // The instance config is fully created and ready to be used to create + // instances. + READY = 2; + } + // A unique identifier for the instance configuration. Values // are of the form // `projects//instanceConfigs/[a-z][-a-z0-9]*`. @@ -315,13 +494,72 @@ message InstanceConfig { // The name of this instance configuration as it appears in UIs. string display_name = 2; + // Output only. Whether this instance config is a Google or User Managed + // Configuration. + Type config_type = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + // The geographic placement of nodes in this instance configuration and their // replication properties. repeated ReplicaInfo replicas = 3; + // Output only. The available optional replicas to choose from for user + // managed configurations. Populated for Google managed configurations. + repeated ReplicaInfo optional_replicas = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Base configuration name, e.g. projects//instanceConfigs/nam3, + // based on which this configuration is created. Only set for user managed + // configurations. `base_config` must refer to a configuration of type + // GOOGLE_MANAGED in the same project as this configuration. + string base_config = 7 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/InstanceConfig" + }]; + + // Cloud Labels are a flexible and lightweight mechanism for organizing cloud + // resources into groups that reflect a customer's organizational needs and + // deployment strategies. Cloud Labels can be used to filter collections of + // resources. They can be used to control how resource metrics are aggregated. + // And they can be used as arguments to policy management rules (e.g. route, + // firewall, load balancing, etc.). + // + // * Label keys must be between 1 and 63 characters long and must conform to + // the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + // * Label values must be between 0 and 63 characters long and must conform + // to the regular expression `[a-z0-9_-]{0,63}`. + // * No more than 64 labels can be associated with a given resource. + // + // See https://goo.gl/xmQnxf for more information on and examples of labels. + // + // If you plan to use labels in your own code, please note that additional + // characters may be allowed in the future. Therefore, you are advised to use + // an internal label representation, such as JSON, which doesn't rely upon + // specific characters being disallowed. For example, representing labels + // as the string: name + "_" + value would prove problematic if we were to + // allow "_" in a future release. + map labels = 8; + + // etag is used for optimistic concurrency control as a way + // to help prevent simultaneous updates of a instance config from overwriting + // each other. It is strongly suggested that systems make use of the etag in + // the read-modify-write cycle to perform instance config updates in order to + // avoid race conditions: An etag is returned in the response which contains + // instance configs, and systems are expected to put that etag in the request + // to update instance config to ensure that their change will be applied to + // the same version of the instance config. + // If no etag is provided in the call to update instance config, then the + // existing instance config is overwritten blindly. + string etag = 9; + // Allowed values of the "default_leader" schema option for databases in // instances that use this instance configuration. repeated string leader_options = 4; + + // Output only. If true, the instance config is being created or updated. If + // false, there are no ongoing operations for the instance config. + bool reconciling = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current instance config state. + State state = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; } // An isolated set of Cloud Spanner resources on which databases can be hosted. @@ -387,10 +625,10 @@ message Instance { int32 processing_units = 9; // Output only. The current instance state. For - // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], the state must be - // either omitted or set to `CREATING`. For - // [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], the state must be - // either omitted or set to `READY`. + // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], + // the state must be either omitted or set to `CREATING`. For + // [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], + // the state must be either omitted or set to `READY`. State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; // Cloud Labels are a flexible and lightweight mechanism for organizing cloud @@ -420,13 +658,16 @@ message Instance { repeated string endpoint_uris = 8; // Output only. The time at which the instance was created. - google.protobuf.Timestamp create_time = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + google.protobuf.Timestamp create_time = 11 + [(google.api.field_behavior) = OUTPUT_ONLY]; // Output only. The time at which the instance was most recently updated. - google.protobuf.Timestamp update_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + google.protobuf.Timestamp update_time = 12 + [(google.api.field_behavior) = OUTPUT_ONLY]; } -// The request for [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. +// The request for +// [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. message ListInstanceConfigsRequest { // Required. The name of the project for which a list of supported instance // configurations is requested. Values are of the form @@ -444,18 +685,20 @@ message ListInstanceConfigsRequest { // If non-empty, `page_token` should contain a // [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token] - // from a previous [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. + // from a previous + // [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. string page_token = 3; } -// The response for [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. +// The response for +// [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. message ListInstanceConfigsResponse { // The list of requested instance configurations. repeated InstanceConfig instance_configs = 1; // `next_page_token` can be sent in a subsequent - // [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs] call to - // fetch more of the matching instance configurations. + // [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs] + // call to fetch more of the matching instance configurations. string next_page_token = 2; } @@ -472,7 +715,175 @@ message GetInstanceConfigRequest { ]; } -// The request for [GetInstance][google.spanner.admin.instance.v1.InstanceAdmin.GetInstance]. +// The request for +// [CreateInstanceConfigRequest][InstanceAdmin.CreateInstanceConfigRequest]. +message CreateInstanceConfigRequest { + // Required. The name of the project in which to create the instance config. + // Values are of the form `projects/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The ID of the instance config to create. Valid identifiers are + // of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + // characters in length. The `custom-` prefix is required to avoid name + // conflicts with Google managed configurations. + string instance_config_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The InstanceConfig proto of the configuration to create. + // instance_config.name must be + // `/instanceConfigs/`. + // instance_config.base_config must be a Google managed configuration name, + // e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + InstanceConfig instance_config = 3 [(google.api.field_behavior) = REQUIRED]; + + // An option to validate, but not actually execute, a request, + // and provide the same response. + bool validate_only = 4; +} + +// The request for +// [UpdateInstanceConfigRequest][InstanceAdmin.UpdateInstanceConfigRequest]. +message UpdateInstanceConfigRequest { + // Required. The user instance config to update, which must always include the + // instance config name. Otherwise, only fields mentioned in + // [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] + // need be included. To prevent conflicts of concurrent updates, + // [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can + // be used. + InstanceConfig instance_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A mask specifying which fields in + // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be + // updated. The field mask must always be specified; this prevents any future + // fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] + // from being erased accidentally by clients that do not know about them. Only + // display_name and labels can be updated. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = REQUIRED]; + + // An option to validate, but not actually execute, a request, + // and provide the same response. + bool validate_only = 3; +} + +// The request for +// [DeleteInstanceConfigRequest][InstanceAdmin.DeleteInstanceConfigRequest]. +message DeleteInstanceConfigRequest { + // Required. The name of the instance configuration to be deleted. + // Values are of the form + // `projects//instanceConfigs/` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/InstanceConfig" + } + ]; + + // Used for optimistic concurrency control as a way to help prevent + // simultaneous deletes of an instance config from overwriting each + // other. If not empty, the API + // only deletes the instance config when the etag provided matches the current + // status of the requested instance config. Otherwise, deletes the instance + // config without checking the current status of the requested instance + // config. + string etag = 2; + + // An option to validate, but not actually execute, a request, + // and provide the same response. + bool validate_only = 3; +} + +// The request for +// [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations]. +message ListInstanceConfigOperationsRequest { + // Required. The project of the instance config operations. + // Values are of the form `projects/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // An expression that filters the list of returned operations. + // + // A filter expression consists of a field name, a + // comparison operator, and a value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [Operation][google.longrunning.Operation] + // are eligible for filtering: + // + // * `name` - The name of the long-running operation + // * `done` - False if the operation is in progress, else true. + // * `metadata.@type` - the type of metadata. For example, the type string + // for + // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata] + // is + // `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + // * `metadata.` - any field in metadata.value. + // `metadata.@type` must be specified first, if filtering on metadata + // fields. + // * `error` - Error associated with the long-running operation. + // * `response.@type` - the type of response. + // * `response.` - any field in response.value. + // + // You can combine multiple expressions by enclosing each expression in + // parentheses. By default, expressions are combined with AND logic. However, + // you can specify AND, OR, and NOT logic explicitly. + // + // Here are a few examples: + // + // * `done:true` - The operation is complete. + // * `(metadata.@type=` \ + // `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + // AND` \ + // `(metadata.instance_config.name:custom-config) AND` \ + // `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + // `(error:*)` - Return operations where: + // * The operation's metadata type is + // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + // * The instance config name contains "custom-config". + // * The operation started before 2021-03-28T14:50:00Z. + // * The operation resulted in an error. + string filter = 2; + + // Number of operations to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token] + // from a previous + // [ListInstanceConfigOperationsResponse][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse] + // to the same `parent` and with the same `filter`. + string page_token = 4; +} + +// The response for +// [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations]. +message ListInstanceConfigOperationsResponse { + // The list of matching instance config [long-running + // operations][google.longrunning.Operation]. Each operation's name will be + // prefixed by the instance config's name. The operation's + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. + repeated google.longrunning.Operation operations = 1; + + // `next_page_token` can be sent in a subsequent + // [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations] + // call to fetch more of the matching metadata. + string next_page_token = 2; +} + +// The request for +// [GetInstance][google.spanner.admin.instance.v1.InstanceAdmin.GetInstance]. message GetInstanceRequest { // Required. The name of the requested instance. Values are of the form // `projects//instances/`. @@ -483,13 +894,15 @@ message GetInstanceRequest { } ]; - // If field_mask is present, specifies the subset of [Instance][google.spanner.admin.instance.v1.Instance] fields that - // should be returned. - // If absent, all [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. + // If field_mask is present, specifies the subset of + // [Instance][google.spanner.admin.instance.v1.Instance] fields that should be + // returned. If absent, all + // [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. google.protobuf.FieldMask field_mask = 2; } -// The request for [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance]. +// The request for +// [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance]. message CreateInstanceRequest { // Required. The name of the project in which to create the instance. Values // are of the form `projects/`. @@ -510,7 +923,8 @@ message CreateInstanceRequest { Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; } -// The request for [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances]. +// The request for +// [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances]. message ListInstancesRequest { // Required. The name of the project for which a list of instances is // requested. Values are of the form `projects/`. @@ -526,8 +940,9 @@ message ListInstancesRequest { int32 page_size = 2; // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token] from a - // previous [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + // [next_page_token][google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token] + // from a previous + // [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. string page_token = 3; // An expression for filtering the results of the request. Filter rules are @@ -552,31 +967,38 @@ message ListInstancesRequest { string filter = 4; } -// The response for [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances]. +// The response for +// [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances]. message ListInstancesResponse { // The list of requested instances. repeated Instance instances = 1; // `next_page_token` can be sent in a subsequent - // [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances] call to fetch more - // of the matching instances. + // [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances] + // call to fetch more of the matching instances. string next_page_token = 2; } -// The request for [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance]. +// The request for +// [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance]. message UpdateInstanceRequest { // Required. The instance to update, which must always include the instance - // name. Otherwise, only fields mentioned in [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included. + // name. Otherwise, only fields mentioned in + // [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] + // need be included. Instance instance = 1 [(google.api.field_behavior) = REQUIRED]; - // Required. A mask specifying which fields in [Instance][google.spanner.admin.instance.v1.Instance] should be updated. + // Required. A mask specifying which fields in + // [Instance][google.spanner.admin.instance.v1.Instance] should be updated. // The field mask must always be specified; this prevents any future fields in - // [Instance][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know - // about them. - google.protobuf.FieldMask field_mask = 2 [(google.api.field_behavior) = REQUIRED]; + // [Instance][google.spanner.admin.instance.v1.Instance] from being erased + // accidentally by clients that do not know about them. + google.protobuf.FieldMask field_mask = 2 + [(google.api.field_behavior) = REQUIRED]; } -// The request for [DeleteInstance][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance]. +// The request for +// [DeleteInstance][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance]. message DeleteInstanceRequest { // Required. The name of the instance to be deleted. Values are of the form // `projects//instances/` @@ -595,8 +1017,8 @@ message CreateInstanceMetadata { Instance instance = 1; // The time at which the - // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance] request was - // received. + // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance] + // request was received. google.protobuf.Timestamp start_time = 2; // The time at which this operation was cancelled. If set, this operation is @@ -614,7 +1036,8 @@ message UpdateInstanceMetadata { // The desired end state of the update. Instance instance = 1; - // The time at which [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance] + // The time at which + // [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance] // request was received. google.protobuf.Timestamp start_time = 2; @@ -626,3 +1049,33 @@ message UpdateInstanceMetadata { // The time at which this operation failed or was completed successfully. google.protobuf.Timestamp end_time = 4; } + +// Metadata type for the operation returned by +// [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig]. +message CreateInstanceConfigMetadata { + // The target instance config end state. + InstanceConfig instance_config = 1; + + // The progress of the + // [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig] + // operation. + OperationProgress progress = 2; + + // The time at which this operation was cancelled. + google.protobuf.Timestamp cancel_time = 3; +} + +// Metadata type for the operation returned by +// [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig]. +message UpdateInstanceConfigMetadata { + // The desired instance config after updating. + InstanceConfig instance_config = 1; + + // The progress of the + // [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig] + // operation. + OperationProgress progress = 2; + + // The time at which this operation was cancelled. + google.protobuf.Timestamp cancel_time = 3; +} diff --git a/protos/google/spanner/v1/type.proto b/protos/google/spanner/v1/type.proto index 126e4a0c2..712ec187f 100644 --- a/protos/google/spanner/v1/type.proto +++ b/protos/google/spanner/v1/type.proto @@ -163,4 +163,12 @@ enum TypeAnnotationCode { // [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with PostgreSQL-enabled // Spanner databases. PG_NUMERIC = 2; + + // PostgreSQL compatible JSONB type. This annotation needs to be applied to + // [Type][google.spanner.v1.Type] instances having [JSON][google.spanner.v1.TypeCode.JSON] + // type code to specify that values of this type should be treated as + // PostgreSQL JSONB values. Currently this annotation is always needed for + // [JSON][google.spanner.v1.TypeCode.JSON] when a client interacts with PostgreSQL-enabled + // Spanner databases. + PG_JSONB = 3; } diff --git a/protos/protos.d.ts b/protos/protos.d.ts index baf40049c..6bd2b7d63 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -10558,6 +10558,115 @@ export namespace google { /** Namespace v1. */ namespace v1 { + /** Properties of an OperationProgress. */ + interface IOperationProgress { + + /** OperationProgress progressPercent */ + progressPercent?: (number|null); + + /** OperationProgress startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** OperationProgress endTime */ + endTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents an OperationProgress. */ + class OperationProgress implements IOperationProgress { + + /** + * Constructs a new OperationProgress. + * @param [properties] Properties to set + */ + constructor(properties?: google.spanner.admin.instance.v1.IOperationProgress); + + /** OperationProgress progressPercent. */ + public progressPercent: number; + + /** OperationProgress startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** OperationProgress endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new OperationProgress instance using the specified properties. + * @param [properties] Properties to set + * @returns OperationProgress instance + */ + public static create(properties?: google.spanner.admin.instance.v1.IOperationProgress): google.spanner.admin.instance.v1.OperationProgress; + + /** + * Encodes the specified OperationProgress message. Does not implicitly {@link google.spanner.admin.instance.v1.OperationProgress.verify|verify} messages. + * @param message OperationProgress message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.spanner.admin.instance.v1.IOperationProgress, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OperationProgress message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.OperationProgress.verify|verify} messages. + * @param message OperationProgress message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.spanner.admin.instance.v1.IOperationProgress, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OperationProgress message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OperationProgress + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.OperationProgress; + + /** + * Decodes an OperationProgress message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OperationProgress + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.OperationProgress; + + /** + * Verifies an OperationProgress message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an OperationProgress message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationProgress + */ + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.OperationProgress; + + /** + * Creates a plain object from an OperationProgress message. Also converts values to other types if specified. + * @param message OperationProgress + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.spanner.admin.instance.v1.OperationProgress, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationProgress to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OperationProgress + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Represents an InstanceAdmin */ class InstanceAdmin extends $protobuf.rpc.Service { @@ -10606,6 +10715,62 @@ export namespace google { */ public getInstanceConfig(request: google.spanner.admin.instance.v1.IGetInstanceConfigRequest): Promise; + /** + * Calls CreateInstanceConfig. + * @param request CreateInstanceConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createInstanceConfig(request: google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, callback: google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfigCallback): void; + + /** + * Calls CreateInstanceConfig. + * @param request CreateInstanceConfigRequest message or plain object + * @returns Promise + */ + public createInstanceConfig(request: google.spanner.admin.instance.v1.ICreateInstanceConfigRequest): Promise; + + /** + * Calls UpdateInstanceConfig. + * @param request UpdateInstanceConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public updateInstanceConfig(request: google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, callback: google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfigCallback): void; + + /** + * Calls UpdateInstanceConfig. + * @param request UpdateInstanceConfigRequest message or plain object + * @returns Promise + */ + public updateInstanceConfig(request: google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest): Promise; + + /** + * Calls DeleteInstanceConfig. + * @param request DeleteInstanceConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteInstanceConfig(request: google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, callback: google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstanceConfigCallback): void; + + /** + * Calls DeleteInstanceConfig. + * @param request DeleteInstanceConfigRequest message or plain object + * @returns Promise + */ + public deleteInstanceConfig(request: google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest): Promise; + + /** + * Calls ListInstanceConfigOperations. + * @param request ListInstanceConfigOperationsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListInstanceConfigOperationsResponse + */ + public listInstanceConfigOperations(request: google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, callback: google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperationsCallback): void; + + /** + * Calls ListInstanceConfigOperations. + * @param request ListInstanceConfigOperationsRequest message or plain object + * @returns Promise + */ + public listInstanceConfigOperations(request: google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest): Promise; + /** * Calls ListInstances. * @param request ListInstancesRequest message or plain object @@ -10735,6 +10900,34 @@ export namespace google { */ type GetInstanceConfigCallback = (error: (Error|null), response?: google.spanner.admin.instance.v1.InstanceConfig) => void; + /** + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|createInstanceConfig}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateInstanceConfigCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|updateInstanceConfig}. + * @param error Error, if any + * @param [response] Operation + */ + type UpdateInstanceConfigCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|deleteInstanceConfig}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteInstanceConfigCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|listInstanceConfigOperations}. + * @param error Error, if any + * @param [response] ListInstanceConfigOperationsResponse + */ + type ListInstanceConfigOperationsCallback = (error: (Error|null), response?: google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse) => void; + /** * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|listInstances}. * @param error Error, if any @@ -10921,11 +11114,32 @@ export namespace google { /** InstanceConfig displayName */ displayName?: (string|null); + /** InstanceConfig configType */ + configType?: (google.spanner.admin.instance.v1.InstanceConfig.Type|keyof typeof google.spanner.admin.instance.v1.InstanceConfig.Type|null); + /** InstanceConfig replicas */ replicas?: (google.spanner.admin.instance.v1.IReplicaInfo[]|null); + /** InstanceConfig optionalReplicas */ + optionalReplicas?: (google.spanner.admin.instance.v1.IReplicaInfo[]|null); + + /** InstanceConfig baseConfig */ + baseConfig?: (string|null); + + /** InstanceConfig labels */ + labels?: ({ [k: string]: string }|null); + + /** InstanceConfig etag */ + etag?: (string|null); + /** InstanceConfig leaderOptions */ leaderOptions?: (string[]|null); + + /** InstanceConfig reconciling */ + reconciling?: (boolean|null); + + /** InstanceConfig state */ + state?: (google.spanner.admin.instance.v1.InstanceConfig.State|keyof typeof google.spanner.admin.instance.v1.InstanceConfig.State|null); } /** Represents an InstanceConfig. */ @@ -10943,12 +11157,33 @@ export namespace google { /** InstanceConfig displayName. */ public displayName: string; + /** InstanceConfig configType. */ + public configType: (google.spanner.admin.instance.v1.InstanceConfig.Type|keyof typeof google.spanner.admin.instance.v1.InstanceConfig.Type); + /** InstanceConfig replicas. */ public replicas: google.spanner.admin.instance.v1.IReplicaInfo[]; + /** InstanceConfig optionalReplicas. */ + public optionalReplicas: google.spanner.admin.instance.v1.IReplicaInfo[]; + + /** InstanceConfig baseConfig. */ + public baseConfig: string; + + /** InstanceConfig labels. */ + public labels: { [k: string]: string }; + + /** InstanceConfig etag. */ + public etag: string; + /** InstanceConfig leaderOptions. */ public leaderOptions: string[]; + /** InstanceConfig reconciling. */ + public reconciling: boolean; + + /** InstanceConfig state. */ + public state: (google.spanner.admin.instance.v1.InstanceConfig.State|keyof typeof google.spanner.admin.instance.v1.InstanceConfig.State); + /** * Creates a new InstanceConfig instance using the specified properties. * @param [properties] Properties to set @@ -11027,6 +11262,23 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace InstanceConfig { + + /** Type enum. */ + enum Type { + TYPE_UNSPECIFIED = 0, + GOOGLE_MANAGED = 1, + USER_MANAGED = 2 + } + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + CREATING = 1, + READY = 2 + } + } + /** Properties of an Instance. */ interface IInstance { @@ -11497,175 +11749,726 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } - /** Properties of a GetInstanceRequest. */ - interface IGetInstanceRequest { + /** Properties of a CreateInstanceConfigRequest. */ + interface ICreateInstanceConfigRequest { - /** GetInstanceRequest name */ - name?: (string|null); + /** CreateInstanceConfigRequest parent */ + parent?: (string|null); - /** GetInstanceRequest fieldMask */ - fieldMask?: (google.protobuf.IFieldMask|null); + /** CreateInstanceConfigRequest instanceConfigId */ + instanceConfigId?: (string|null); + + /** CreateInstanceConfigRequest instanceConfig */ + instanceConfig?: (google.spanner.admin.instance.v1.IInstanceConfig|null); + + /** CreateInstanceConfigRequest validateOnly */ + validateOnly?: (boolean|null); } - /** Represents a GetInstanceRequest. */ - class GetInstanceRequest implements IGetInstanceRequest { + /** Represents a CreateInstanceConfigRequest. */ + class CreateInstanceConfigRequest implements ICreateInstanceConfigRequest { /** - * Constructs a new GetInstanceRequest. + * Constructs a new CreateInstanceConfigRequest. * @param [properties] Properties to set */ - constructor(properties?: google.spanner.admin.instance.v1.IGetInstanceRequest); + constructor(properties?: google.spanner.admin.instance.v1.ICreateInstanceConfigRequest); - /** GetInstanceRequest name. */ - public name: string; + /** CreateInstanceConfigRequest parent. */ + public parent: string; - /** GetInstanceRequest fieldMask. */ - public fieldMask?: (google.protobuf.IFieldMask|null); + /** CreateInstanceConfigRequest instanceConfigId. */ + public instanceConfigId: string; + + /** CreateInstanceConfigRequest instanceConfig. */ + public instanceConfig?: (google.spanner.admin.instance.v1.IInstanceConfig|null); + + /** CreateInstanceConfigRequest validateOnly. */ + public validateOnly: boolean; /** - * Creates a new GetInstanceRequest instance using the specified properties. + * Creates a new CreateInstanceConfigRequest instance using the specified properties. * @param [properties] Properties to set - * @returns GetInstanceRequest instance + * @returns CreateInstanceConfigRequest instance */ - public static create(properties?: google.spanner.admin.instance.v1.IGetInstanceRequest): google.spanner.admin.instance.v1.GetInstanceRequest; + public static create(properties?: google.spanner.admin.instance.v1.ICreateInstanceConfigRequest): google.spanner.admin.instance.v1.CreateInstanceConfigRequest; /** - * Encodes the specified GetInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceRequest.verify|verify} messages. - * @param message GetInstanceRequest message or plain object to encode + * Encodes the specified CreateInstanceConfigRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceConfigRequest.verify|verify} messages. + * @param message CreateInstanceConfigRequest message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.spanner.admin.instance.v1.IGetInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified GetInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceRequest.verify|verify} messages. - * @param message GetInstanceRequest message or plain object to encode + * Encodes the specified CreateInstanceConfigRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceConfigRequest.verify|verify} messages. + * @param message CreateInstanceConfigRequest message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.spanner.admin.instance.v1.IGetInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a GetInstanceRequest message from the specified reader or buffer. + * Decodes a CreateInstanceConfigRequest message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns GetInstanceRequest + * @returns CreateInstanceConfigRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.GetInstanceRequest; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.CreateInstanceConfigRequest; /** - * Decodes a GetInstanceRequest message from the specified reader or buffer, length delimited. + * Decodes a CreateInstanceConfigRequest message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns GetInstanceRequest + * @returns CreateInstanceConfigRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.GetInstanceRequest; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.CreateInstanceConfigRequest; /** - * Verifies a GetInstanceRequest message. + * Verifies a CreateInstanceConfigRequest message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a GetInstanceRequest message from a plain object. Also converts values to their respective internal types. + * Creates a CreateInstanceConfigRequest message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns GetInstanceRequest + * @returns CreateInstanceConfigRequest */ - public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.GetInstanceRequest; + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.CreateInstanceConfigRequest; /** - * Creates a plain object from a GetInstanceRequest message. Also converts values to other types if specified. - * @param message GetInstanceRequest + * Creates a plain object from a CreateInstanceConfigRequest message. Also converts values to other types if specified. + * @param message CreateInstanceConfigRequest * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.spanner.admin.instance.v1.GetInstanceRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.spanner.admin.instance.v1.CreateInstanceConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this GetInstanceRequest to JSON. + * Converts this CreateInstanceConfigRequest to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; /** - * Gets the default type url for GetInstanceRequest + * Gets the default type url for CreateInstanceConfigRequest * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns The default type url */ public static getTypeUrl(typeUrlPrefix?: string): string; } - /** Properties of a CreateInstanceRequest. */ - interface ICreateInstanceRequest { + /** Properties of an UpdateInstanceConfigRequest. */ + interface IUpdateInstanceConfigRequest { - /** CreateInstanceRequest parent */ - parent?: (string|null); + /** UpdateInstanceConfigRequest instanceConfig */ + instanceConfig?: (google.spanner.admin.instance.v1.IInstanceConfig|null); - /** CreateInstanceRequest instanceId */ - instanceId?: (string|null); + /** UpdateInstanceConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); - /** CreateInstanceRequest instance */ - instance?: (google.spanner.admin.instance.v1.IInstance|null); + /** UpdateInstanceConfigRequest validateOnly */ + validateOnly?: (boolean|null); } - /** Represents a CreateInstanceRequest. */ - class CreateInstanceRequest implements ICreateInstanceRequest { + /** Represents an UpdateInstanceConfigRequest. */ + class UpdateInstanceConfigRequest implements IUpdateInstanceConfigRequest { /** - * Constructs a new CreateInstanceRequest. + * Constructs a new UpdateInstanceConfigRequest. * @param [properties] Properties to set */ - constructor(properties?: google.spanner.admin.instance.v1.ICreateInstanceRequest); + constructor(properties?: google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest); - /** CreateInstanceRequest parent. */ - public parent: string; + /** UpdateInstanceConfigRequest instanceConfig. */ + public instanceConfig?: (google.spanner.admin.instance.v1.IInstanceConfig|null); - /** CreateInstanceRequest instanceId. */ - public instanceId: string; + /** UpdateInstanceConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); - /** CreateInstanceRequest instance. */ - public instance?: (google.spanner.admin.instance.v1.IInstance|null); + /** UpdateInstanceConfigRequest validateOnly. */ + public validateOnly: boolean; /** - * Creates a new CreateInstanceRequest instance using the specified properties. + * Creates a new UpdateInstanceConfigRequest instance using the specified properties. * @param [properties] Properties to set - * @returns CreateInstanceRequest instance + * @returns UpdateInstanceConfigRequest instance */ - public static create(properties?: google.spanner.admin.instance.v1.ICreateInstanceRequest): google.spanner.admin.instance.v1.CreateInstanceRequest; + public static create(properties?: google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest): google.spanner.admin.instance.v1.UpdateInstanceConfigRequest; /** - * Encodes the specified CreateInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceRequest.verify|verify} messages. - * @param message CreateInstanceRequest message or plain object to encode + * Encodes the specified UpdateInstanceConfigRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.verify|verify} messages. + * @param message UpdateInstanceConfigRequest message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.spanner.admin.instance.v1.ICreateInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified CreateInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceRequest.verify|verify} messages. - * @param message CreateInstanceRequest message or plain object to encode + * Encodes the specified UpdateInstanceConfigRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.verify|verify} messages. + * @param message UpdateInstanceConfigRequest message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.spanner.admin.instance.v1.ICreateInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a CreateInstanceRequest message from the specified reader or buffer. + * Decodes an UpdateInstanceConfigRequest message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns CreateInstanceRequest + * @returns UpdateInstanceConfigRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.CreateInstanceRequest; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.UpdateInstanceConfigRequest; /** - * Decodes a CreateInstanceRequest message from the specified reader or buffer, length delimited. + * Decodes an UpdateInstanceConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.UpdateInstanceConfigRequest; + + /** + * Verifies an UpdateInstanceConfigRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdateInstanceConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateInstanceConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.UpdateInstanceConfigRequest; + + /** + * Creates a plain object from an UpdateInstanceConfigRequest message. Also converts values to other types if specified. + * @param message UpdateInstanceConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.spanner.admin.instance.v1.UpdateInstanceConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateInstanceConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateInstanceConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteInstanceConfigRequest. */ + interface IDeleteInstanceConfigRequest { + + /** DeleteInstanceConfigRequest name */ + name?: (string|null); + + /** DeleteInstanceConfigRequest etag */ + etag?: (string|null); + + /** DeleteInstanceConfigRequest validateOnly */ + validateOnly?: (boolean|null); + } + + /** Represents a DeleteInstanceConfigRequest. */ + class DeleteInstanceConfigRequest implements IDeleteInstanceConfigRequest { + + /** + * Constructs a new DeleteInstanceConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest); + + /** DeleteInstanceConfigRequest name. */ + public name: string; + + /** DeleteInstanceConfigRequest etag. */ + public etag: string; + + /** DeleteInstanceConfigRequest validateOnly. */ + public validateOnly: boolean; + + /** + * Creates a new DeleteInstanceConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteInstanceConfigRequest instance + */ + public static create(properties?: google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest): google.spanner.admin.instance.v1.DeleteInstanceConfigRequest; + + /** + * Encodes the specified DeleteInstanceConfigRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.DeleteInstanceConfigRequest.verify|verify} messages. + * @param message DeleteInstanceConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteInstanceConfigRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.DeleteInstanceConfigRequest.verify|verify} messages. + * @param message DeleteInstanceConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteInstanceConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.DeleteInstanceConfigRequest; + + /** + * Decodes a DeleteInstanceConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.DeleteInstanceConfigRequest; + + /** + * Verifies a DeleteInstanceConfigRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteInstanceConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteInstanceConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.DeleteInstanceConfigRequest; + + /** + * Creates a plain object from a DeleteInstanceConfigRequest message. Also converts values to other types if specified. + * @param message DeleteInstanceConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.spanner.admin.instance.v1.DeleteInstanceConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteInstanceConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteInstanceConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListInstanceConfigOperationsRequest. */ + interface IListInstanceConfigOperationsRequest { + + /** ListInstanceConfigOperationsRequest parent */ + parent?: (string|null); + + /** ListInstanceConfigOperationsRequest filter */ + filter?: (string|null); + + /** ListInstanceConfigOperationsRequest pageSize */ + pageSize?: (number|null); + + /** ListInstanceConfigOperationsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListInstanceConfigOperationsRequest. */ + class ListInstanceConfigOperationsRequest implements IListInstanceConfigOperationsRequest { + + /** + * Constructs a new ListInstanceConfigOperationsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest); + + /** ListInstanceConfigOperationsRequest parent. */ + public parent: string; + + /** ListInstanceConfigOperationsRequest filter. */ + public filter: string; + + /** ListInstanceConfigOperationsRequest pageSize. */ + public pageSize: number; + + /** ListInstanceConfigOperationsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListInstanceConfigOperationsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListInstanceConfigOperationsRequest instance + */ + public static create(properties?: google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest): google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest; + + /** + * Encodes the specified ListInstanceConfigOperationsRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest.verify|verify} messages. + * @param message ListInstanceConfigOperationsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListInstanceConfigOperationsRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest.verify|verify} messages. + * @param message ListInstanceConfigOperationsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListInstanceConfigOperationsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListInstanceConfigOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest; + + /** + * Decodes a ListInstanceConfigOperationsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListInstanceConfigOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest; + + /** + * Verifies a ListInstanceConfigOperationsRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListInstanceConfigOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListInstanceConfigOperationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest; + + /** + * Creates a plain object from a ListInstanceConfigOperationsRequest message. Also converts values to other types if specified. + * @param message ListInstanceConfigOperationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListInstanceConfigOperationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListInstanceConfigOperationsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListInstanceConfigOperationsResponse. */ + interface IListInstanceConfigOperationsResponse { + + /** ListInstanceConfigOperationsResponse operations */ + operations?: (google.longrunning.IOperation[]|null); + + /** ListInstanceConfigOperationsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListInstanceConfigOperationsResponse. */ + class ListInstanceConfigOperationsResponse implements IListInstanceConfigOperationsResponse { + + /** + * Constructs a new ListInstanceConfigOperationsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse); + + /** ListInstanceConfigOperationsResponse operations. */ + public operations: google.longrunning.IOperation[]; + + /** ListInstanceConfigOperationsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListInstanceConfigOperationsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListInstanceConfigOperationsResponse instance + */ + public static create(properties?: google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse): google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse; + + /** + * Encodes the specified ListInstanceConfigOperationsResponse message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.verify|verify} messages. + * @param message ListInstanceConfigOperationsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListInstanceConfigOperationsResponse message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.verify|verify} messages. + * @param message ListInstanceConfigOperationsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListInstanceConfigOperationsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListInstanceConfigOperationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse; + + /** + * Decodes a ListInstanceConfigOperationsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListInstanceConfigOperationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse; + + /** + * Verifies a ListInstanceConfigOperationsResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListInstanceConfigOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListInstanceConfigOperationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse; + + /** + * Creates a plain object from a ListInstanceConfigOperationsResponse message. Also converts values to other types if specified. + * @param message ListInstanceConfigOperationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListInstanceConfigOperationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListInstanceConfigOperationsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetInstanceRequest. */ + interface IGetInstanceRequest { + + /** GetInstanceRequest name */ + name?: (string|null); + + /** GetInstanceRequest fieldMask */ + fieldMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents a GetInstanceRequest. */ + class GetInstanceRequest implements IGetInstanceRequest { + + /** + * Constructs a new GetInstanceRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.spanner.admin.instance.v1.IGetInstanceRequest); + + /** GetInstanceRequest name. */ + public name: string; + + /** GetInstanceRequest fieldMask. */ + public fieldMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new GetInstanceRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetInstanceRequest instance + */ + public static create(properties?: google.spanner.admin.instance.v1.IGetInstanceRequest): google.spanner.admin.instance.v1.GetInstanceRequest; + + /** + * Encodes the specified GetInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceRequest.verify|verify} messages. + * @param message GetInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.spanner.admin.instance.v1.IGetInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceRequest.verify|verify} messages. + * @param message GetInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.spanner.admin.instance.v1.IGetInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetInstanceRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetInstanceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.GetInstanceRequest; + + /** + * Decodes a GetInstanceRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetInstanceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.GetInstanceRequest; + + /** + * Verifies a GetInstanceRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetInstanceRequest + */ + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.GetInstanceRequest; + + /** + * Creates a plain object from a GetInstanceRequest message. Also converts values to other types if specified. + * @param message GetInstanceRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.spanner.admin.instance.v1.GetInstanceRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetInstanceRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetInstanceRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CreateInstanceRequest. */ + interface ICreateInstanceRequest { + + /** CreateInstanceRequest parent */ + parent?: (string|null); + + /** CreateInstanceRequest instanceId */ + instanceId?: (string|null); + + /** CreateInstanceRequest instance */ + instance?: (google.spanner.admin.instance.v1.IInstance|null); + } + + /** Represents a CreateInstanceRequest. */ + class CreateInstanceRequest implements ICreateInstanceRequest { + + /** + * Constructs a new CreateInstanceRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.spanner.admin.instance.v1.ICreateInstanceRequest); + + /** CreateInstanceRequest parent. */ + public parent: string; + + /** CreateInstanceRequest instanceId. */ + public instanceId: string; + + /** CreateInstanceRequest instance. */ + public instance?: (google.spanner.admin.instance.v1.IInstance|null); + + /** + * Creates a new CreateInstanceRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateInstanceRequest instance + */ + public static create(properties?: google.spanner.admin.instance.v1.ICreateInstanceRequest): google.spanner.admin.instance.v1.CreateInstanceRequest; + + /** + * Encodes the specified CreateInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceRequest.verify|verify} messages. + * @param message CreateInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.spanner.admin.instance.v1.ICreateInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceRequest.verify|verify} messages. + * @param message CreateInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.spanner.admin.instance.v1.ICreateInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateInstanceRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateInstanceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.CreateInstanceRequest; + + /** + * Decodes a CreateInstanceRequest message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from * @returns CreateInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer @@ -12356,6 +13159,224 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a CreateInstanceConfigMetadata. */ + interface ICreateInstanceConfigMetadata { + + /** CreateInstanceConfigMetadata instanceConfig */ + instanceConfig?: (google.spanner.admin.instance.v1.IInstanceConfig|null); + + /** CreateInstanceConfigMetadata progress */ + progress?: (google.spanner.admin.instance.v1.IOperationProgress|null); + + /** CreateInstanceConfigMetadata cancelTime */ + cancelTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a CreateInstanceConfigMetadata. */ + class CreateInstanceConfigMetadata implements ICreateInstanceConfigMetadata { + + /** + * Constructs a new CreateInstanceConfigMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata); + + /** CreateInstanceConfigMetadata instanceConfig. */ + public instanceConfig?: (google.spanner.admin.instance.v1.IInstanceConfig|null); + + /** CreateInstanceConfigMetadata progress. */ + public progress?: (google.spanner.admin.instance.v1.IOperationProgress|null); + + /** CreateInstanceConfigMetadata cancelTime. */ + public cancelTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new CreateInstanceConfigMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateInstanceConfigMetadata instance + */ + public static create(properties?: google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata): google.spanner.admin.instance.v1.CreateInstanceConfigMetadata; + + /** + * Encodes the specified CreateInstanceConfigMetadata message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata.verify|verify} messages. + * @param message CreateInstanceConfigMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateInstanceConfigMetadata message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata.verify|verify} messages. + * @param message CreateInstanceConfigMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateInstanceConfigMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateInstanceConfigMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.CreateInstanceConfigMetadata; + + /** + * Decodes a CreateInstanceConfigMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateInstanceConfigMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.CreateInstanceConfigMetadata; + + /** + * Verifies a CreateInstanceConfigMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateInstanceConfigMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateInstanceConfigMetadata + */ + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.CreateInstanceConfigMetadata; + + /** + * Creates a plain object from a CreateInstanceConfigMetadata message. Also converts values to other types if specified. + * @param message CreateInstanceConfigMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.spanner.admin.instance.v1.CreateInstanceConfigMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateInstanceConfigMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateInstanceConfigMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateInstanceConfigMetadata. */ + interface IUpdateInstanceConfigMetadata { + + /** UpdateInstanceConfigMetadata instanceConfig */ + instanceConfig?: (google.spanner.admin.instance.v1.IInstanceConfig|null); + + /** UpdateInstanceConfigMetadata progress */ + progress?: (google.spanner.admin.instance.v1.IOperationProgress|null); + + /** UpdateInstanceConfigMetadata cancelTime */ + cancelTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents an UpdateInstanceConfigMetadata. */ + class UpdateInstanceConfigMetadata implements IUpdateInstanceConfigMetadata { + + /** + * Constructs a new UpdateInstanceConfigMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata); + + /** UpdateInstanceConfigMetadata instanceConfig. */ + public instanceConfig?: (google.spanner.admin.instance.v1.IInstanceConfig|null); + + /** UpdateInstanceConfigMetadata progress. */ + public progress?: (google.spanner.admin.instance.v1.IOperationProgress|null); + + /** UpdateInstanceConfigMetadata cancelTime. */ + public cancelTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new UpdateInstanceConfigMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateInstanceConfigMetadata instance + */ + public static create(properties?: google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata): google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata; + + /** + * Encodes the specified UpdateInstanceConfigMetadata message. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.verify|verify} messages. + * @param message UpdateInstanceConfigMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateInstanceConfigMetadata message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.verify|verify} messages. + * @param message UpdateInstanceConfigMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateInstanceConfigMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateInstanceConfigMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata; + + /** + * Decodes an UpdateInstanceConfigMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateInstanceConfigMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata; + + /** + * Verifies an UpdateInstanceConfigMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdateInstanceConfigMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateInstanceConfigMetadata + */ + public static fromObject(object: { [k: string]: any }): google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata; + + /** + * Creates a plain object from an UpdateInstanceConfigMetadata message. Also converts values to other types if specified. + * @param message UpdateInstanceConfigMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateInstanceConfigMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateInstanceConfigMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } } } @@ -15017,7 +16038,8 @@ export namespace google { /** TypeAnnotationCode enum. */ enum TypeAnnotationCode { TYPE_ANNOTATION_CODE_UNSPECIFIED = 0, - PG_NUMERIC = 2 + PG_NUMERIC = 2, + PG_JSONB = 3 } /** Represents a Spanner */ diff --git a/protos/protos.js b/protos/protos.js index 3b346ae20..b50e559c6 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -26354,6 +26354,266 @@ */ var v1 = {}; + v1.OperationProgress = (function() { + + /** + * Properties of an OperationProgress. + * @memberof google.spanner.admin.instance.v1 + * @interface IOperationProgress + * @property {number|null} [progressPercent] OperationProgress progressPercent + * @property {google.protobuf.ITimestamp|null} [startTime] OperationProgress startTime + * @property {google.protobuf.ITimestamp|null} [endTime] OperationProgress endTime + */ + + /** + * Constructs a new OperationProgress. + * @memberof google.spanner.admin.instance.v1 + * @classdesc Represents an OperationProgress. + * @implements IOperationProgress + * @constructor + * @param {google.spanner.admin.instance.v1.IOperationProgress=} [properties] Properties to set + */ + function OperationProgress(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OperationProgress progressPercent. + * @member {number} progressPercent + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @instance + */ + OperationProgress.prototype.progressPercent = 0; + + /** + * OperationProgress startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @instance + */ + OperationProgress.prototype.startTime = null; + + /** + * OperationProgress endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @instance + */ + OperationProgress.prototype.endTime = null; + + /** + * Creates a new OperationProgress instance using the specified properties. + * @function create + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {google.spanner.admin.instance.v1.IOperationProgress=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.OperationProgress} OperationProgress instance + */ + OperationProgress.create = function create(properties) { + return new OperationProgress(properties); + }; + + /** + * Encodes the specified OperationProgress message. Does not implicitly {@link google.spanner.admin.instance.v1.OperationProgress.verify|verify} messages. + * @function encode + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {google.spanner.admin.instance.v1.IOperationProgress} message OperationProgress message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperationProgress.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.progressPercent != null && Object.hasOwnProperty.call(message, "progressPercent")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.progressPercent); + if (message.startTime != null && Object.hasOwnProperty.call(message, "startTime")) + $root.google.protobuf.Timestamp.encode(message.startTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.endTime != null && Object.hasOwnProperty.call(message, "endTime")) + $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OperationProgress message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.OperationProgress.verify|verify} messages. + * @function encodeDelimited + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {google.spanner.admin.instance.v1.IOperationProgress} message OperationProgress message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperationProgress.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OperationProgress message from the specified reader or buffer. + * @function decode + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.spanner.admin.instance.v1.OperationProgress} OperationProgress + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperationProgress.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.OperationProgress(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.progressPercent = reader.int32(); + break; + } + case 2: { + message.startTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OperationProgress message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.spanner.admin.instance.v1.OperationProgress} OperationProgress + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperationProgress.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OperationProgress message. + * @function verify + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OperationProgress.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.progressPercent != null && message.hasOwnProperty("progressPercent")) + if (!$util.isInteger(message.progressPercent)) + return "progressPercent: integer expected"; + if (message.startTime != null && message.hasOwnProperty("startTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.startTime); + if (error) + return "startTime." + error; + } + if (message.endTime != null && message.hasOwnProperty("endTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.endTime); + if (error) + return "endTime." + error; + } + return null; + }; + + /** + * Creates an OperationProgress message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.OperationProgress} OperationProgress + */ + OperationProgress.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.OperationProgress) + return object; + var message = new $root.google.spanner.admin.instance.v1.OperationProgress(); + if (object.progressPercent != null) + message.progressPercent = object.progressPercent | 0; + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.spanner.admin.instance.v1.OperationProgress.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.spanner.admin.instance.v1.OperationProgress.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + return message; + }; + + /** + * Creates a plain object from an OperationProgress message. Also converts values to other types if specified. + * @function toObject + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {google.spanner.admin.instance.v1.OperationProgress} message OperationProgress + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OperationProgress.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.progressPercent = 0; + object.startTime = null; + object.endTime = null; + } + if (message.progressPercent != null && message.hasOwnProperty("progressPercent")) + object.progressPercent = message.progressPercent; + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + return object; + }; + + /** + * Converts this OperationProgress to JSON. + * @function toJSON + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @instance + * @returns {Object.} JSON object + */ + OperationProgress.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OperationProgress + * @function getTypeUrl + * @memberof google.spanner.admin.instance.v1.OperationProgress + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OperationProgress.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.spanner.admin.instance.v1.OperationProgress"; + }; + + return OperationProgress; + })(); + v1.InstanceAdmin = (function() { /** @@ -26453,59 +26713,191 @@ */ /** - * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|listInstances}. + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|createInstanceConfig}. * @memberof google.spanner.admin.instance.v1.InstanceAdmin - * @typedef ListInstancesCallback + * @typedef CreateInstanceConfigCallback * @type {function} * @param {Error|null} error Error, if any - * @param {google.spanner.admin.instance.v1.ListInstancesResponse} [response] ListInstancesResponse + * @param {google.longrunning.Operation} [response] Operation */ /** - * Calls ListInstances. - * @function listInstances + * Calls CreateInstanceConfig. + * @function createInstanceConfig * @memberof google.spanner.admin.instance.v1.InstanceAdmin * @instance - * @param {google.spanner.admin.instance.v1.IListInstancesRequest} request ListInstancesRequest message or plain object - * @param {google.spanner.admin.instance.v1.InstanceAdmin.ListInstancesCallback} callback Node-style callback called with the error, if any, and ListInstancesResponse + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigRequest} request CreateInstanceConfigRequest message or plain object + * @param {google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfigCallback} callback Node-style callback called with the error, if any, and Operation * @returns {undefined} * @variation 1 */ - Object.defineProperty(InstanceAdmin.prototype.listInstances = function listInstances(request, callback) { - return this.rpcCall(listInstances, $root.google.spanner.admin.instance.v1.ListInstancesRequest, $root.google.spanner.admin.instance.v1.ListInstancesResponse, request, callback); - }, "name", { value: "ListInstances" }); + Object.defineProperty(InstanceAdmin.prototype.createInstanceConfig = function createInstanceConfig(request, callback) { + return this.rpcCall(createInstanceConfig, $root.google.spanner.admin.instance.v1.CreateInstanceConfigRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateInstanceConfig" }); /** - * Calls ListInstances. - * @function listInstances + * Calls CreateInstanceConfig. + * @function createInstanceConfig * @memberof google.spanner.admin.instance.v1.InstanceAdmin * @instance - * @param {google.spanner.admin.instance.v1.IListInstancesRequest} request ListInstancesRequest message or plain object - * @returns {Promise} Promise + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigRequest} request CreateInstanceConfigRequest message or plain object + * @returns {Promise} Promise * @variation 2 */ /** - * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|getInstance}. + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|updateInstanceConfig}. * @memberof google.spanner.admin.instance.v1.InstanceAdmin - * @typedef GetInstanceCallback + * @typedef UpdateInstanceConfigCallback * @type {function} * @param {Error|null} error Error, if any - * @param {google.spanner.admin.instance.v1.Instance} [response] Instance + * @param {google.longrunning.Operation} [response] Operation */ /** - * Calls GetInstance. - * @function getInstance + * Calls UpdateInstanceConfig. + * @function updateInstanceConfig * @memberof google.spanner.admin.instance.v1.InstanceAdmin * @instance - * @param {google.spanner.admin.instance.v1.IGetInstanceRequest} request GetInstanceRequest message or plain object - * @param {google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceCallback} callback Node-style callback called with the error, if any, and Instance + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest} request UpdateInstanceConfigRequest message or plain object + * @param {google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfigCallback} callback Node-style callback called with the error, if any, and Operation * @returns {undefined} * @variation 1 */ - Object.defineProperty(InstanceAdmin.prototype.getInstance = function getInstance(request, callback) { - return this.rpcCall(getInstance, $root.google.spanner.admin.instance.v1.GetInstanceRequest, $root.google.spanner.admin.instance.v1.Instance, request, callback); + Object.defineProperty(InstanceAdmin.prototype.updateInstanceConfig = function updateInstanceConfig(request, callback) { + return this.rpcCall(updateInstanceConfig, $root.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UpdateInstanceConfig" }); + + /** + * Calls UpdateInstanceConfig. + * @function updateInstanceConfig + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @instance + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest} request UpdateInstanceConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|deleteInstanceConfig}. + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @typedef DeleteInstanceConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteInstanceConfig. + * @function deleteInstanceConfig + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @instance + * @param {google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest} request DeleteInstanceConfigRequest message or plain object + * @param {google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstanceConfigCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(InstanceAdmin.prototype.deleteInstanceConfig = function deleteInstanceConfig(request, callback) { + return this.rpcCall(deleteInstanceConfig, $root.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteInstanceConfig" }); + + /** + * Calls DeleteInstanceConfig. + * @function deleteInstanceConfig + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @instance + * @param {google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest} request DeleteInstanceConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|listInstanceConfigOperations}. + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @typedef ListInstanceConfigOperationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse} [response] ListInstanceConfigOperationsResponse + */ + + /** + * Calls ListInstanceConfigOperations. + * @function listInstanceConfigOperations + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @instance + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest} request ListInstanceConfigOperationsRequest message or plain object + * @param {google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperationsCallback} callback Node-style callback called with the error, if any, and ListInstanceConfigOperationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(InstanceAdmin.prototype.listInstanceConfigOperations = function listInstanceConfigOperations(request, callback) { + return this.rpcCall(listInstanceConfigOperations, $root.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest, $root.google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse, request, callback); + }, "name", { value: "ListInstanceConfigOperations" }); + + /** + * Calls ListInstanceConfigOperations. + * @function listInstanceConfigOperations + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @instance + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest} request ListInstanceConfigOperationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|listInstances}. + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @typedef ListInstancesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.spanner.admin.instance.v1.ListInstancesResponse} [response] ListInstancesResponse + */ + + /** + * Calls ListInstances. + * @function listInstances + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @instance + * @param {google.spanner.admin.instance.v1.IListInstancesRequest} request ListInstancesRequest message or plain object + * @param {google.spanner.admin.instance.v1.InstanceAdmin.ListInstancesCallback} callback Node-style callback called with the error, if any, and ListInstancesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(InstanceAdmin.prototype.listInstances = function listInstances(request, callback) { + return this.rpcCall(listInstances, $root.google.spanner.admin.instance.v1.ListInstancesRequest, $root.google.spanner.admin.instance.v1.ListInstancesResponse, request, callback); + }, "name", { value: "ListInstances" }); + + /** + * Calls ListInstances. + * @function listInstances + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @instance + * @param {google.spanner.admin.instance.v1.IListInstancesRequest} request ListInstancesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.spanner.admin.instance.v1.InstanceAdmin|getInstance}. + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @typedef GetInstanceCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.spanner.admin.instance.v1.Instance} [response] Instance + */ + + /** + * Calls GetInstance. + * @function getInstance + * @memberof google.spanner.admin.instance.v1.InstanceAdmin + * @instance + * @param {google.spanner.admin.instance.v1.IGetInstanceRequest} request GetInstanceRequest message or plain object + * @param {google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceCallback} callback Node-style callback called with the error, if any, and Instance + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(InstanceAdmin.prototype.getInstance = function getInstance(request, callback) { + return this.rpcCall(getInstance, $root.google.spanner.admin.instance.v1.GetInstanceRequest, $root.google.spanner.admin.instance.v1.Instance, request, callback); }, "name", { value: "GetInstance" }); /** @@ -27018,8 +27410,15 @@ * @interface IInstanceConfig * @property {string|null} [name] InstanceConfig name * @property {string|null} [displayName] InstanceConfig displayName + * @property {google.spanner.admin.instance.v1.InstanceConfig.Type|null} [configType] InstanceConfig configType * @property {Array.|null} [replicas] InstanceConfig replicas + * @property {Array.|null} [optionalReplicas] InstanceConfig optionalReplicas + * @property {string|null} [baseConfig] InstanceConfig baseConfig + * @property {Object.|null} [labels] InstanceConfig labels + * @property {string|null} [etag] InstanceConfig etag * @property {Array.|null} [leaderOptions] InstanceConfig leaderOptions + * @property {boolean|null} [reconciling] InstanceConfig reconciling + * @property {google.spanner.admin.instance.v1.InstanceConfig.State|null} [state] InstanceConfig state */ /** @@ -27032,6 +27431,8 @@ */ function InstanceConfig(properties) { this.replicas = []; + this.optionalReplicas = []; + this.labels = {}; this.leaderOptions = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) @@ -27055,6 +27456,14 @@ */ InstanceConfig.prototype.displayName = ""; + /** + * InstanceConfig configType. + * @member {google.spanner.admin.instance.v1.InstanceConfig.Type} configType + * @memberof google.spanner.admin.instance.v1.InstanceConfig + * @instance + */ + InstanceConfig.prototype.configType = 0; + /** * InstanceConfig replicas. * @member {Array.} replicas @@ -27063,6 +27472,38 @@ */ InstanceConfig.prototype.replicas = $util.emptyArray; + /** + * InstanceConfig optionalReplicas. + * @member {Array.} optionalReplicas + * @memberof google.spanner.admin.instance.v1.InstanceConfig + * @instance + */ + InstanceConfig.prototype.optionalReplicas = $util.emptyArray; + + /** + * InstanceConfig baseConfig. + * @member {string} baseConfig + * @memberof google.spanner.admin.instance.v1.InstanceConfig + * @instance + */ + InstanceConfig.prototype.baseConfig = ""; + + /** + * InstanceConfig labels. + * @member {Object.} labels + * @memberof google.spanner.admin.instance.v1.InstanceConfig + * @instance + */ + InstanceConfig.prototype.labels = $util.emptyObject; + + /** + * InstanceConfig etag. + * @member {string} etag + * @memberof google.spanner.admin.instance.v1.InstanceConfig + * @instance + */ + InstanceConfig.prototype.etag = ""; + /** * InstanceConfig leaderOptions. * @member {Array.} leaderOptions @@ -27071,6 +27512,22 @@ */ InstanceConfig.prototype.leaderOptions = $util.emptyArray; + /** + * InstanceConfig reconciling. + * @member {boolean} reconciling + * @memberof google.spanner.admin.instance.v1.InstanceConfig + * @instance + */ + InstanceConfig.prototype.reconciling = false; + + /** + * InstanceConfig state. + * @member {google.spanner.admin.instance.v1.InstanceConfig.State} state + * @memberof google.spanner.admin.instance.v1.InstanceConfig + * @instance + */ + InstanceConfig.prototype.state = 0; + /** * Creates a new InstanceConfig instance using the specified properties. * @function create @@ -27105,6 +27562,22 @@ if (message.leaderOptions != null && message.leaderOptions.length) for (var i = 0; i < message.leaderOptions.length; ++i) writer.uint32(/* id 4, wireType 2 =*/34).string(message.leaderOptions[i]); + if (message.configType != null && Object.hasOwnProperty.call(message, "configType")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.configType); + if (message.optionalReplicas != null && message.optionalReplicas.length) + for (var i = 0; i < message.optionalReplicas.length; ++i) + $root.google.spanner.admin.instance.v1.ReplicaInfo.encode(message.optionalReplicas[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.baseConfig != null && Object.hasOwnProperty.call(message, "baseConfig")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.baseConfig); + if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 8, wireType 2 =*/66).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.etag); + if (message.reconciling != null && Object.hasOwnProperty.call(message, "reconciling")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.reconciling); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.state); return writer; }; @@ -27135,7 +27608,7 @@ InstanceConfig.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.InstanceConfig(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.InstanceConfig(), key, value; while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { @@ -27147,18 +27620,67 @@ message.displayName = reader.string(); break; } + case 5: { + message.configType = reader.int32(); + break; + } case 3: { if (!(message.replicas && message.replicas.length)) message.replicas = []; message.replicas.push($root.google.spanner.admin.instance.v1.ReplicaInfo.decode(reader, reader.uint32())); break; } + case 6: { + if (!(message.optionalReplicas && message.optionalReplicas.length)) + message.optionalReplicas = []; + message.optionalReplicas.push($root.google.spanner.admin.instance.v1.ReplicaInfo.decode(reader, reader.uint32())); + break; + } + case 7: { + message.baseConfig = reader.string(); + break; + } + case 8: { + if (message.labels === $util.emptyObject) + message.labels = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.labels[key] = value; + break; + } + case 9: { + message.etag = reader.string(); + break; + } case 4: { if (!(message.leaderOptions && message.leaderOptions.length)) message.leaderOptions = []; message.leaderOptions.push(reader.string()); break; } + case 10: { + message.reconciling = reader.bool(); + break; + } + case 11: { + message.state = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -27200,6 +27722,15 @@ if (message.displayName != null && message.hasOwnProperty("displayName")) if (!$util.isString(message.displayName)) return "displayName: string expected"; + if (message.configType != null && message.hasOwnProperty("configType")) + switch (message.configType) { + default: + return "configType: enum value expected"; + case 0: + case 1: + case 2: + break; + } if (message.replicas != null && message.hasOwnProperty("replicas")) { if (!Array.isArray(message.replicas)) return "replicas: array expected"; @@ -27209,6 +27740,29 @@ return "replicas." + error; } } + if (message.optionalReplicas != null && message.hasOwnProperty("optionalReplicas")) { + if (!Array.isArray(message.optionalReplicas)) + return "optionalReplicas: array expected"; + for (var i = 0; i < message.optionalReplicas.length; ++i) { + var error = $root.google.spanner.admin.instance.v1.ReplicaInfo.verify(message.optionalReplicas[i]); + if (error) + return "optionalReplicas." + error; + } + } + if (message.baseConfig != null && message.hasOwnProperty("baseConfig")) + if (!$util.isString(message.baseConfig)) + return "baseConfig: string expected"; + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; if (message.leaderOptions != null && message.hasOwnProperty("leaderOptions")) { if (!Array.isArray(message.leaderOptions)) return "leaderOptions: array expected"; @@ -27216,6 +27770,18 @@ if (!$util.isString(message.leaderOptions[i])) return "leaderOptions: string[] expected"; } + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + if (typeof message.reconciling !== "boolean") + return "reconciling: boolean expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -27235,6 +27801,20 @@ message.name = String(object.name); if (object.displayName != null) message.displayName = String(object.displayName); + switch (object.configType) { + case "TYPE_UNSPECIFIED": + case 0: + message.configType = 0; + break; + case "GOOGLE_MANAGED": + case 1: + message.configType = 1; + break; + case "USER_MANAGED": + case 2: + message.configType = 2; + break; + } if (object.replicas) { if (!Array.isArray(object.replicas)) throw TypeError(".google.spanner.admin.instance.v1.InstanceConfig.replicas: array expected"); @@ -27245,6 +27825,27 @@ message.replicas[i] = $root.google.spanner.admin.instance.v1.ReplicaInfo.fromObject(object.replicas[i]); } } + if (object.optionalReplicas) { + if (!Array.isArray(object.optionalReplicas)) + throw TypeError(".google.spanner.admin.instance.v1.InstanceConfig.optionalReplicas: array expected"); + message.optionalReplicas = []; + for (var i = 0; i < object.optionalReplicas.length; ++i) { + if (typeof object.optionalReplicas[i] !== "object") + throw TypeError(".google.spanner.admin.instance.v1.InstanceConfig.optionalReplicas: object expected"); + message.optionalReplicas[i] = $root.google.spanner.admin.instance.v1.ReplicaInfo.fromObject(object.optionalReplicas[i]); + } + } + if (object.baseConfig != null) + message.baseConfig = String(object.baseConfig); + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.spanner.admin.instance.v1.InstanceConfig.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + if (object.etag != null) + message.etag = String(object.etag); if (object.leaderOptions) { if (!Array.isArray(object.leaderOptions)) throw TypeError(".google.spanner.admin.instance.v1.InstanceConfig.leaderOptions: array expected"); @@ -27252,6 +27853,22 @@ for (var i = 0; i < object.leaderOptions.length; ++i) message.leaderOptions[i] = String(object.leaderOptions[i]); } + if (object.reconciling != null) + message.reconciling = Boolean(object.reconciling); + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "CREATING": + case 1: + message.state = 1; + break; + case "READY": + case 2: + message.state = 2; + break; + } return message; }; @@ -27271,10 +27888,18 @@ if (options.arrays || options.defaults) { object.replicas = []; object.leaderOptions = []; + object.optionalReplicas = []; } + if (options.objects || options.defaults) + object.labels = {}; if (options.defaults) { object.name = ""; object.displayName = ""; + object.configType = options.enums === String ? "TYPE_UNSPECIFIED" : 0; + object.baseConfig = ""; + object.etag = ""; + object.reconciling = false; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -27290,6 +27915,27 @@ for (var j = 0; j < message.leaderOptions.length; ++j) object.leaderOptions[j] = message.leaderOptions[j]; } + if (message.configType != null && message.hasOwnProperty("configType")) + object.configType = options.enums === String ? $root.google.spanner.admin.instance.v1.InstanceConfig.Type[message.configType] : message.configType; + if (message.optionalReplicas && message.optionalReplicas.length) { + object.optionalReplicas = []; + for (var j = 0; j < message.optionalReplicas.length; ++j) + object.optionalReplicas[j] = $root.google.spanner.admin.instance.v1.ReplicaInfo.toObject(message.optionalReplicas[j], options); + } + if (message.baseConfig != null && message.hasOwnProperty("baseConfig")) + object.baseConfig = message.baseConfig; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + object.reconciling = message.reconciling; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.spanner.admin.instance.v1.InstanceConfig.State[message.state] : message.state; return object; }; @@ -27319,11 +27965,43 @@ return typeUrlPrefix + "/google.spanner.admin.instance.v1.InstanceConfig"; }; - return InstanceConfig; - })(); - - v1.Instance = (function() { - + /** + * Type enum. + * @name google.spanner.admin.instance.v1.InstanceConfig.Type + * @enum {number} + * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value + * @property {number} GOOGLE_MANAGED=1 GOOGLE_MANAGED value + * @property {number} USER_MANAGED=2 USER_MANAGED value + */ + InstanceConfig.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "GOOGLE_MANAGED"] = 1; + values[valuesById[2] = "USER_MANAGED"] = 2; + return values; + })(); + + /** + * State enum. + * @name google.spanner.admin.instance.v1.InstanceConfig.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} CREATING=1 CREATING value + * @property {number} READY=2 READY value + */ + InstanceConfig.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "CREATING"] = 1; + values[valuesById[2] = "READY"] = 2; + return values; + })(); + + return InstanceConfig; + })(); + + v1.Instance = (function() { + /** * Properties of an Instance. * @memberof google.spanner.admin.instance.v1 @@ -27897,63 +28575,1814 @@ * @function encode * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstanceConfigsRequest} message ListInstanceConfigsRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IListInstanceConfigsRequest} message ListInstanceConfigsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstanceConfigsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + return writer; + }; + + /** + * Encodes the specified ListInstanceConfigsRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigsRequest} message ListInstanceConfigsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstanceConfigsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListInstanceConfigsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsRequest} ListInstanceConfigsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListInstanceConfigsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListInstanceConfigsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsRequest} ListInstanceConfigsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListInstanceConfigsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListInstanceConfigsRequest message. + * @function verify + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListInstanceConfigsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * Creates a ListInstanceConfigsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsRequest} ListInstanceConfigsRequest + */ + ListInstanceConfigsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.ListInstanceConfigsRequest) + return object; + var message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListInstanceConfigsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @static + * @param {google.spanner.admin.instance.v1.ListInstanceConfigsRequest} message ListInstanceConfigsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListInstanceConfigsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListInstanceConfigsRequest to JSON. + * @function toJSON + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @instance + * @returns {Object.} JSON object + */ + ListInstanceConfigsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListInstanceConfigsRequest + * @function getTypeUrl + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListInstanceConfigsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstanceConfigsRequest"; + }; + + return ListInstanceConfigsRequest; + })(); + + v1.ListInstanceConfigsResponse = (function() { + + /** + * Properties of a ListInstanceConfigsResponse. + * @memberof google.spanner.admin.instance.v1 + * @interface IListInstanceConfigsResponse + * @property {Array.|null} [instanceConfigs] ListInstanceConfigsResponse instanceConfigs + * @property {string|null} [nextPageToken] ListInstanceConfigsResponse nextPageToken + */ + + /** + * Constructs a new ListInstanceConfigsResponse. + * @memberof google.spanner.admin.instance.v1 + * @classdesc Represents a ListInstanceConfigsResponse. + * @implements IListInstanceConfigsResponse + * @constructor + * @param {google.spanner.admin.instance.v1.IListInstanceConfigsResponse=} [properties] Properties to set + */ + function ListInstanceConfigsResponse(properties) { + this.instanceConfigs = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListInstanceConfigsResponse instanceConfigs. + * @member {Array.} instanceConfigs + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @instance + */ + ListInstanceConfigsResponse.prototype.instanceConfigs = $util.emptyArray; + + /** + * ListInstanceConfigsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @instance + */ + ListInstanceConfigsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListInstanceConfigsResponse instance using the specified properties. + * @function create + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigsResponse=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} ListInstanceConfigsResponse instance + */ + ListInstanceConfigsResponse.create = function create(properties) { + return new ListInstanceConfigsResponse(properties); + }; + + /** + * Encodes the specified ListInstanceConfigsResponse message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.verify|verify} messages. + * @function encode + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigsResponse} message ListInstanceConfigsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstanceConfigsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.instanceConfigs != null && message.instanceConfigs.length) + for (var i = 0; i < message.instanceConfigs.length; ++i) + $root.google.spanner.admin.instance.v1.InstanceConfig.encode(message.instanceConfigs[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListInstanceConfigsResponse message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigsResponse} message ListInstanceConfigsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstanceConfigsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListInstanceConfigsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} ListInstanceConfigsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListInstanceConfigsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.instanceConfigs && message.instanceConfigs.length)) + message.instanceConfigs = []; + message.instanceConfigs.push($root.google.spanner.admin.instance.v1.InstanceConfig.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListInstanceConfigsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} ListInstanceConfigsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListInstanceConfigsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListInstanceConfigsResponse message. + * @function verify + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListInstanceConfigsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.instanceConfigs != null && message.hasOwnProperty("instanceConfigs")) { + if (!Array.isArray(message.instanceConfigs)) + return "instanceConfigs: array expected"; + for (var i = 0; i < message.instanceConfigs.length; ++i) { + var error = $root.google.spanner.admin.instance.v1.InstanceConfig.verify(message.instanceConfigs[i]); + if (error) + return "instanceConfigs." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListInstanceConfigsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} ListInstanceConfigsResponse + */ + ListInstanceConfigsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.ListInstanceConfigsResponse) + return object; + var message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigsResponse(); + if (object.instanceConfigs) { + if (!Array.isArray(object.instanceConfigs)) + throw TypeError(".google.spanner.admin.instance.v1.ListInstanceConfigsResponse.instanceConfigs: array expected"); + message.instanceConfigs = []; + for (var i = 0; i < object.instanceConfigs.length; ++i) { + if (typeof object.instanceConfigs[i] !== "object") + throw TypeError(".google.spanner.admin.instance.v1.ListInstanceConfigsResponse.instanceConfigs: object expected"); + message.instanceConfigs[i] = $root.google.spanner.admin.instance.v1.InstanceConfig.fromObject(object.instanceConfigs[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListInstanceConfigsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} message ListInstanceConfigsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListInstanceConfigsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.instanceConfigs = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.instanceConfigs && message.instanceConfigs.length) { + object.instanceConfigs = []; + for (var j = 0; j < message.instanceConfigs.length; ++j) + object.instanceConfigs[j] = $root.google.spanner.admin.instance.v1.InstanceConfig.toObject(message.instanceConfigs[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListInstanceConfigsResponse to JSON. + * @function toJSON + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @instance + * @returns {Object.} JSON object + */ + ListInstanceConfigsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListInstanceConfigsResponse + * @function getTypeUrl + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListInstanceConfigsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstanceConfigsResponse"; + }; + + return ListInstanceConfigsResponse; + })(); + + v1.GetInstanceConfigRequest = (function() { + + /** + * Properties of a GetInstanceConfigRequest. + * @memberof google.spanner.admin.instance.v1 + * @interface IGetInstanceConfigRequest + * @property {string|null} [name] GetInstanceConfigRequest name + */ + + /** + * Constructs a new GetInstanceConfigRequest. + * @memberof google.spanner.admin.instance.v1 + * @classdesc Represents a GetInstanceConfigRequest. + * @implements IGetInstanceConfigRequest + * @constructor + * @param {google.spanner.admin.instance.v1.IGetInstanceConfigRequest=} [properties] Properties to set + */ + function GetInstanceConfigRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetInstanceConfigRequest name. + * @member {string} name + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @instance + */ + GetInstanceConfigRequest.prototype.name = ""; + + /** + * Creates a new GetInstanceConfigRequest instance using the specified properties. + * @function create + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IGetInstanceConfigRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.GetInstanceConfigRequest} GetInstanceConfigRequest instance + */ + GetInstanceConfigRequest.create = function create(properties) { + return new GetInstanceConfigRequest(properties); + }; + + /** + * Encodes the specified GetInstanceConfigRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IGetInstanceConfigRequest} message GetInstanceConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetInstanceConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetInstanceConfigRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IGetInstanceConfigRequest} message GetInstanceConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetInstanceConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetInstanceConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.spanner.admin.instance.v1.GetInstanceConfigRequest} GetInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetInstanceConfigRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.GetInstanceConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetInstanceConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.spanner.admin.instance.v1.GetInstanceConfigRequest} GetInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetInstanceConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetInstanceConfigRequest message. + * @function verify + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetInstanceConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetInstanceConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.GetInstanceConfigRequest} GetInstanceConfigRequest + */ + GetInstanceConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.GetInstanceConfigRequest) + return object; + var message = new $root.google.spanner.admin.instance.v1.GetInstanceConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetInstanceConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.GetInstanceConfigRequest} message GetInstanceConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetInstanceConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetInstanceConfigRequest to JSON. + * @function toJSON + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetInstanceConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetInstanceConfigRequest + * @function getTypeUrl + * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetInstanceConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.spanner.admin.instance.v1.GetInstanceConfigRequest"; + }; + + return GetInstanceConfigRequest; + })(); + + v1.CreateInstanceConfigRequest = (function() { + + /** + * Properties of a CreateInstanceConfigRequest. + * @memberof google.spanner.admin.instance.v1 + * @interface ICreateInstanceConfigRequest + * @property {string|null} [parent] CreateInstanceConfigRequest parent + * @property {string|null} [instanceConfigId] CreateInstanceConfigRequest instanceConfigId + * @property {google.spanner.admin.instance.v1.IInstanceConfig|null} [instanceConfig] CreateInstanceConfigRequest instanceConfig + * @property {boolean|null} [validateOnly] CreateInstanceConfigRequest validateOnly + */ + + /** + * Constructs a new CreateInstanceConfigRequest. + * @memberof google.spanner.admin.instance.v1 + * @classdesc Represents a CreateInstanceConfigRequest. + * @implements ICreateInstanceConfigRequest + * @constructor + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigRequest=} [properties] Properties to set + */ + function CreateInstanceConfigRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateInstanceConfigRequest parent. + * @member {string} parent + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @instance + */ + CreateInstanceConfigRequest.prototype.parent = ""; + + /** + * CreateInstanceConfigRequest instanceConfigId. + * @member {string} instanceConfigId + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @instance + */ + CreateInstanceConfigRequest.prototype.instanceConfigId = ""; + + /** + * CreateInstanceConfigRequest instanceConfig. + * @member {google.spanner.admin.instance.v1.IInstanceConfig|null|undefined} instanceConfig + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @instance + */ + CreateInstanceConfigRequest.prototype.instanceConfig = null; + + /** + * CreateInstanceConfigRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @instance + */ + CreateInstanceConfigRequest.prototype.validateOnly = false; + + /** + * Creates a new CreateInstanceConfigRequest instance using the specified properties. + * @function create + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.CreateInstanceConfigRequest} CreateInstanceConfigRequest instance + */ + CreateInstanceConfigRequest.create = function create(properties) { + return new CreateInstanceConfigRequest(properties); + }; + + /** + * Encodes the specified CreateInstanceConfigRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigRequest} message CreateInstanceConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateInstanceConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.instanceConfigId != null && Object.hasOwnProperty.call(message, "instanceConfigId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.instanceConfigId); + if (message.instanceConfig != null && Object.hasOwnProperty.call(message, "instanceConfig")) + $root.google.spanner.admin.instance.v1.InstanceConfig.encode(message.instanceConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified CreateInstanceConfigRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigRequest} message CreateInstanceConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateInstanceConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateInstanceConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.spanner.admin.instance.v1.CreateInstanceConfigRequest} CreateInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateInstanceConfigRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.CreateInstanceConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.instanceConfigId = reader.string(); + break; + } + case 3: { + message.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.decode(reader, reader.uint32()); + break; + } + case 4: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateInstanceConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.spanner.admin.instance.v1.CreateInstanceConfigRequest} CreateInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateInstanceConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateInstanceConfigRequest message. + * @function verify + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateInstanceConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.instanceConfigId != null && message.hasOwnProperty("instanceConfigId")) + if (!$util.isString(message.instanceConfigId)) + return "instanceConfigId: string expected"; + if (message.instanceConfig != null && message.hasOwnProperty("instanceConfig")) { + var error = $root.google.spanner.admin.instance.v1.InstanceConfig.verify(message.instanceConfig); + if (error) + return "instanceConfig." + error; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates a CreateInstanceConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.CreateInstanceConfigRequest} CreateInstanceConfigRequest + */ + CreateInstanceConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.CreateInstanceConfigRequest) + return object; + var message = new $root.google.spanner.admin.instance.v1.CreateInstanceConfigRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.instanceConfigId != null) + message.instanceConfigId = String(object.instanceConfigId); + if (object.instanceConfig != null) { + if (typeof object.instanceConfig !== "object") + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceConfigRequest.instanceConfig: object expected"); + message.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.fromObject(object.instanceConfig); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from a CreateInstanceConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.CreateInstanceConfigRequest} message CreateInstanceConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateInstanceConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.instanceConfigId = ""; + object.instanceConfig = null; + object.validateOnly = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.instanceConfigId != null && message.hasOwnProperty("instanceConfigId")) + object.instanceConfigId = message.instanceConfigId; + if (message.instanceConfig != null && message.hasOwnProperty("instanceConfig")) + object.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.toObject(message.instanceConfig, options); + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this CreateInstanceConfigRequest to JSON. + * @function toJSON + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @instance + * @returns {Object.} JSON object + */ + CreateInstanceConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateInstanceConfigRequest + * @function getTypeUrl + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateInstanceConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.spanner.admin.instance.v1.CreateInstanceConfigRequest"; + }; + + return CreateInstanceConfigRequest; + })(); + + v1.UpdateInstanceConfigRequest = (function() { + + /** + * Properties of an UpdateInstanceConfigRequest. + * @memberof google.spanner.admin.instance.v1 + * @interface IUpdateInstanceConfigRequest + * @property {google.spanner.admin.instance.v1.IInstanceConfig|null} [instanceConfig] UpdateInstanceConfigRequest instanceConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateInstanceConfigRequest updateMask + * @property {boolean|null} [validateOnly] UpdateInstanceConfigRequest validateOnly + */ + + /** + * Constructs a new UpdateInstanceConfigRequest. + * @memberof google.spanner.admin.instance.v1 + * @classdesc Represents an UpdateInstanceConfigRequest. + * @implements IUpdateInstanceConfigRequest + * @constructor + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest=} [properties] Properties to set + */ + function UpdateInstanceConfigRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdateInstanceConfigRequest instanceConfig. + * @member {google.spanner.admin.instance.v1.IInstanceConfig|null|undefined} instanceConfig + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @instance + */ + UpdateInstanceConfigRequest.prototype.instanceConfig = null; + + /** + * UpdateInstanceConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @instance + */ + UpdateInstanceConfigRequest.prototype.updateMask = null; + + /** + * UpdateInstanceConfigRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @instance + */ + UpdateInstanceConfigRequest.prototype.validateOnly = false; + + /** + * Creates a new UpdateInstanceConfigRequest instance using the specified properties. + * @function create + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.UpdateInstanceConfigRequest} UpdateInstanceConfigRequest instance + */ + UpdateInstanceConfigRequest.create = function create(properties) { + return new UpdateInstanceConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateInstanceConfigRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest} message UpdateInstanceConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateInstanceConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.instanceConfig != null && Object.hasOwnProperty.call(message, "instanceConfig")) + $root.google.spanner.admin.instance.v1.InstanceConfig.encode(message.instanceConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified UpdateInstanceConfigRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest} message UpdateInstanceConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateInstanceConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateInstanceConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.spanner.admin.instance.v1.UpdateInstanceConfigRequest} UpdateInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateInstanceConfigRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 3: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateInstanceConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.spanner.admin.instance.v1.UpdateInstanceConfigRequest} UpdateInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateInstanceConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateInstanceConfigRequest message. + * @function verify + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateInstanceConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.instanceConfig != null && message.hasOwnProperty("instanceConfig")) { + var error = $root.google.spanner.admin.instance.v1.InstanceConfig.verify(message.instanceConfig); + if (error) + return "instanceConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates an UpdateInstanceConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.UpdateInstanceConfigRequest} UpdateInstanceConfigRequest + */ + UpdateInstanceConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest) + return object; + var message = new $root.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest(); + if (object.instanceConfig != null) { + if (typeof object.instanceConfig !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.instanceConfig: object expected"); + message.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.fromObject(object.instanceConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from an UpdateInstanceConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.UpdateInstanceConfigRequest} message UpdateInstanceConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateInstanceConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.instanceConfig = null; + object.updateMask = null; + object.validateOnly = false; + } + if (message.instanceConfig != null && message.hasOwnProperty("instanceConfig")) + object.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.toObject(message.instanceConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this UpdateInstanceConfigRequest to JSON. + * @function toJSON + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateInstanceConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateInstanceConfigRequest + * @function getTypeUrl + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateInstanceConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.spanner.admin.instance.v1.UpdateInstanceConfigRequest"; + }; + + return UpdateInstanceConfigRequest; + })(); + + v1.DeleteInstanceConfigRequest = (function() { + + /** + * Properties of a DeleteInstanceConfigRequest. + * @memberof google.spanner.admin.instance.v1 + * @interface IDeleteInstanceConfigRequest + * @property {string|null} [name] DeleteInstanceConfigRequest name + * @property {string|null} [etag] DeleteInstanceConfigRequest etag + * @property {boolean|null} [validateOnly] DeleteInstanceConfigRequest validateOnly + */ + + /** + * Constructs a new DeleteInstanceConfigRequest. + * @memberof google.spanner.admin.instance.v1 + * @classdesc Represents a DeleteInstanceConfigRequest. + * @implements IDeleteInstanceConfigRequest + * @constructor + * @param {google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest=} [properties] Properties to set + */ + function DeleteInstanceConfigRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteInstanceConfigRequest name. + * @member {string} name + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @instance + */ + DeleteInstanceConfigRequest.prototype.name = ""; + + /** + * DeleteInstanceConfigRequest etag. + * @member {string} etag + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @instance + */ + DeleteInstanceConfigRequest.prototype.etag = ""; + + /** + * DeleteInstanceConfigRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @instance + */ + DeleteInstanceConfigRequest.prototype.validateOnly = false; + + /** + * Creates a new DeleteInstanceConfigRequest instance using the specified properties. + * @function create + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.DeleteInstanceConfigRequest} DeleteInstanceConfigRequest instance + */ + DeleteInstanceConfigRequest.create = function create(properties) { + return new DeleteInstanceConfigRequest(properties); + }; + + /** + * Encodes the specified DeleteInstanceConfigRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.DeleteInstanceConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest} message DeleteInstanceConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteInstanceConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.etag); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified DeleteInstanceConfigRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.DeleteInstanceConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest} message DeleteInstanceConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteInstanceConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteInstanceConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.spanner.admin.instance.v1.DeleteInstanceConfigRequest} DeleteInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteInstanceConfigRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.etag = reader.string(); + break; + } + case 3: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteInstanceConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.spanner.admin.instance.v1.DeleteInstanceConfigRequest} DeleteInstanceConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteInstanceConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteInstanceConfigRequest message. + * @function verify + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteInstanceConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates a DeleteInstanceConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.DeleteInstanceConfigRequest} DeleteInstanceConfigRequest + */ + DeleteInstanceConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest) + return object; + var message = new $root.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.etag != null) + message.etag = String(object.etag); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from a DeleteInstanceConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {google.spanner.admin.instance.v1.DeleteInstanceConfigRequest} message DeleteInstanceConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteInstanceConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.etag = ""; + object.validateOnly = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this DeleteInstanceConfigRequest to JSON. + * @function toJSON + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteInstanceConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteInstanceConfigRequest + * @function getTypeUrl + * @memberof google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteInstanceConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.spanner.admin.instance.v1.DeleteInstanceConfigRequest"; + }; + + return DeleteInstanceConfigRequest; + })(); + + v1.ListInstanceConfigOperationsRequest = (function() { + + /** + * Properties of a ListInstanceConfigOperationsRequest. + * @memberof google.spanner.admin.instance.v1 + * @interface IListInstanceConfigOperationsRequest + * @property {string|null} [parent] ListInstanceConfigOperationsRequest parent + * @property {string|null} [filter] ListInstanceConfigOperationsRequest filter + * @property {number|null} [pageSize] ListInstanceConfigOperationsRequest pageSize + * @property {string|null} [pageToken] ListInstanceConfigOperationsRequest pageToken + */ + + /** + * Constructs a new ListInstanceConfigOperationsRequest. + * @memberof google.spanner.admin.instance.v1 + * @classdesc Represents a ListInstanceConfigOperationsRequest. + * @implements IListInstanceConfigOperationsRequest + * @constructor + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest=} [properties] Properties to set + */ + function ListInstanceConfigOperationsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListInstanceConfigOperationsRequest parent. + * @member {string} parent + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @instance + */ + ListInstanceConfigOperationsRequest.prototype.parent = ""; + + /** + * ListInstanceConfigOperationsRequest filter. + * @member {string} filter + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @instance + */ + ListInstanceConfigOperationsRequest.prototype.filter = ""; + + /** + * ListInstanceConfigOperationsRequest pageSize. + * @member {number} pageSize + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @instance + */ + ListInstanceConfigOperationsRequest.prototype.pageSize = 0; + + /** + * ListInstanceConfigOperationsRequest pageToken. + * @member {string} pageToken + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @instance + */ + ListInstanceConfigOperationsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListInstanceConfigOperationsRequest instance using the specified properties. + * @function create + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest} ListInstanceConfigOperationsRequest instance + */ + ListInstanceConfigOperationsRequest.create = function create(properties) { + return new ListInstanceConfigOperationsRequest(properties); + }; + + /** + * Encodes the specified ListInstanceConfigOperationsRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest.verify|verify} messages. + * @function encode + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest} message ListInstanceConfigOperationsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstanceConfigOperationsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.filter); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.pageToken); + return writer; + }; + + /** + * Encodes the specified ListInstanceConfigOperationsRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest} message ListInstanceConfigOperationsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstanceConfigOperationsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListInstanceConfigOperationsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest} ListInstanceConfigOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListInstanceConfigOperationsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.filter = reader.string(); + break; + } + case 3: { + message.pageSize = reader.int32(); + break; + } + case 4: { + message.pageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListInstanceConfigOperationsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest} ListInstanceConfigOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListInstanceConfigOperationsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListInstanceConfigOperationsRequest message. + * @function verify + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListInstanceConfigOperationsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * Creates a ListInstanceConfigOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest} ListInstanceConfigOperationsRequest + */ + ListInstanceConfigOperationsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest) + return object; + var message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.filter != null) + message.filter = String(object.filter); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListInstanceConfigOperationsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest} message ListInstanceConfigOperationsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListInstanceConfigOperationsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.filter = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListInstanceConfigOperationsRequest to JSON. + * @function toJSON + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @instance + * @returns {Object.} JSON object + */ + ListInstanceConfigOperationsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListInstanceConfigOperationsRequest + * @function getTypeUrl + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListInstanceConfigOperationsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest"; + }; + + return ListInstanceConfigOperationsRequest; + })(); + + v1.ListInstanceConfigOperationsResponse = (function() { + + /** + * Properties of a ListInstanceConfigOperationsResponse. + * @memberof google.spanner.admin.instance.v1 + * @interface IListInstanceConfigOperationsResponse + * @property {Array.|null} [operations] ListInstanceConfigOperationsResponse operations + * @property {string|null} [nextPageToken] ListInstanceConfigOperationsResponse nextPageToken + */ + + /** + * Constructs a new ListInstanceConfigOperationsResponse. + * @memberof google.spanner.admin.instance.v1 + * @classdesc Represents a ListInstanceConfigOperationsResponse. + * @implements IListInstanceConfigOperationsResponse + * @constructor + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse=} [properties] Properties to set + */ + function ListInstanceConfigOperationsResponse(properties) { + this.operations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListInstanceConfigOperationsResponse operations. + * @member {Array.} operations + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse + * @instance + */ + ListInstanceConfigOperationsResponse.prototype.operations = $util.emptyArray; + + /** + * ListInstanceConfigOperationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse + * @instance + */ + ListInstanceConfigOperationsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListInstanceConfigOperationsResponse instance using the specified properties. + * @function create + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse} ListInstanceConfigOperationsResponse instance + */ + ListInstanceConfigOperationsResponse.create = function create(properties) { + return new ListInstanceConfigOperationsResponse(properties); + }; + + /** + * Encodes the specified ListInstanceConfigOperationsResponse message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.verify|verify} messages. + * @function encode + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse + * @static + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse} message ListInstanceConfigOperationsResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ListInstanceConfigsRequest.encode = function encode(message, writer) { + ListInstanceConfigOperationsResponse.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); - if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.operations != null && message.operations.length) + for (var i = 0; i < message.operations.length; ++i) + $root.google.longrunning.Operation.encode(message.operations[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); return writer; }; /** - * Encodes the specified ListInstanceConfigsRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigsRequest.verify|verify} messages. + * Encodes the specified ListInstanceConfigOperationsResponse message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse * @static - * @param {google.spanner.admin.instance.v1.IListInstanceConfigsRequest} message ListInstanceConfigsRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse} message ListInstanceConfigOperationsResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ListInstanceConfigsRequest.encodeDelimited = function encodeDelimited(message, writer) { + ListInstanceConfigOperationsResponse.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ListInstanceConfigsRequest message from the specified reader or buffer. + * Decodes a ListInstanceConfigOperationsResponse message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsRequest} ListInstanceConfigsRequest + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse} ListInstanceConfigOperationsResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ListInstanceConfigsRequest.decode = function decode(reader, length) { + ListInstanceConfigOperationsResponse.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigsRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.parent = reader.string(); + if (!(message.operations && message.operations.length)) + message.operations = []; + message.operations.push($root.google.longrunning.Operation.decode(reader, reader.uint32())); break; } case 2: { - message.pageSize = reader.int32(); - break; - } - case 3: { - message.pageToken = reader.string(); + message.nextPageToken = reader.string(); break; } default: @@ -27965,141 +30394,149 @@ }; /** - * Decodes a ListInstanceConfigsRequest message from the specified reader or buffer, length delimited. + * Decodes a ListInstanceConfigOperationsResponse message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsRequest} ListInstanceConfigsRequest + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse} ListInstanceConfigOperationsResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ListInstanceConfigsRequest.decodeDelimited = function decodeDelimited(reader) { + ListInstanceConfigOperationsResponse.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ListInstanceConfigsRequest message. + * Verifies a ListInstanceConfigOperationsResponse message. * @function verify - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ListInstanceConfigsRequest.verify = function verify(message) { + ListInstanceConfigOperationsResponse.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.parent != null && message.hasOwnProperty("parent")) - if (!$util.isString(message.parent)) - return "parent: string expected"; - if (message.pageSize != null && message.hasOwnProperty("pageSize")) - if (!$util.isInteger(message.pageSize)) - return "pageSize: integer expected"; - if (message.pageToken != null && message.hasOwnProperty("pageToken")) - if (!$util.isString(message.pageToken)) - return "pageToken: string expected"; + if (message.operations != null && message.hasOwnProperty("operations")) { + if (!Array.isArray(message.operations)) + return "operations: array expected"; + for (var i = 0; i < message.operations.length; ++i) { + var error = $root.google.longrunning.Operation.verify(message.operations[i]); + if (error) + return "operations." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; return null; }; /** - * Creates a ListInstanceConfigsRequest message from a plain object. Also converts values to their respective internal types. + * Creates a ListInstanceConfigOperationsResponse message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsRequest} ListInstanceConfigsRequest + * @returns {google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse} ListInstanceConfigOperationsResponse */ - ListInstanceConfigsRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.ListInstanceConfigsRequest) + ListInstanceConfigOperationsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse) return object; - var message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigsRequest(); - if (object.parent != null) - message.parent = String(object.parent); - if (object.pageSize != null) - message.pageSize = object.pageSize | 0; - if (object.pageToken != null) - message.pageToken = String(object.pageToken); + var message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse(); + if (object.operations) { + if (!Array.isArray(object.operations)) + throw TypeError(".google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.operations: array expected"); + message.operations = []; + for (var i = 0; i < object.operations.length; ++i) { + if (typeof object.operations[i] !== "object") + throw TypeError(".google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.operations: object expected"); + message.operations[i] = $root.google.longrunning.Operation.fromObject(object.operations[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); return message; }; /** - * Creates a plain object from a ListInstanceConfigsRequest message. Also converts values to other types if specified. + * Creates a plain object from a ListInstanceConfigOperationsResponse message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse * @static - * @param {google.spanner.admin.instance.v1.ListInstanceConfigsRequest} message ListInstanceConfigsRequest + * @param {google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse} message ListInstanceConfigOperationsResponse * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ListInstanceConfigsRequest.toObject = function toObject(message, options) { + ListInstanceConfigOperationsResponse.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) { - object.parent = ""; - object.pageSize = 0; - object.pageToken = ""; + if (options.arrays || options.defaults) + object.operations = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.operations && message.operations.length) { + object.operations = []; + for (var j = 0; j < message.operations.length; ++j) + object.operations[j] = $root.google.longrunning.Operation.toObject(message.operations[j], options); } - if (message.parent != null && message.hasOwnProperty("parent")) - object.parent = message.parent; - if (message.pageSize != null && message.hasOwnProperty("pageSize")) - object.pageSize = message.pageSize; - if (message.pageToken != null && message.hasOwnProperty("pageToken")) - object.pageToken = message.pageToken; + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; return object; }; /** - * Converts this ListInstanceConfigsRequest to JSON. + * Converts this ListInstanceConfigOperationsResponse to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse * @instance * @returns {Object.} JSON object */ - ListInstanceConfigsRequest.prototype.toJSON = function toJSON() { + ListInstanceConfigOperationsResponse.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for ListInstanceConfigsRequest + * Gets the default type url for ListInstanceConfigOperationsResponse * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsRequest + * @memberof google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ListInstanceConfigsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + ListInstanceConfigOperationsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstanceConfigsRequest"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse"; }; - return ListInstanceConfigsRequest; + return ListInstanceConfigOperationsResponse; })(); - v1.ListInstanceConfigsResponse = (function() { + v1.GetInstanceRequest = (function() { /** - * Properties of a ListInstanceConfigsResponse. + * Properties of a GetInstanceRequest. * @memberof google.spanner.admin.instance.v1 - * @interface IListInstanceConfigsResponse - * @property {Array.|null} [instanceConfigs] ListInstanceConfigsResponse instanceConfigs - * @property {string|null} [nextPageToken] ListInstanceConfigsResponse nextPageToken + * @interface IGetInstanceRequest + * @property {string|null} [name] GetInstanceRequest name + * @property {google.protobuf.IFieldMask|null} [fieldMask] GetInstanceRequest fieldMask */ /** - * Constructs a new ListInstanceConfigsResponse. + * Constructs a new GetInstanceRequest. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents a ListInstanceConfigsResponse. - * @implements IListInstanceConfigsResponse + * @classdesc Represents a GetInstanceRequest. + * @implements IGetInstanceRequest * @constructor - * @param {google.spanner.admin.instance.v1.IListInstanceConfigsResponse=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.IGetInstanceRequest=} [properties] Properties to set */ - function ListInstanceConfigsResponse(properties) { - this.instanceConfigs = []; + function GetInstanceRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -28107,92 +30544,89 @@ } /** - * ListInstanceConfigsResponse instanceConfigs. - * @member {Array.} instanceConfigs - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * GetInstanceRequest name. + * @member {string} name + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @instance */ - ListInstanceConfigsResponse.prototype.instanceConfigs = $util.emptyArray; + GetInstanceRequest.prototype.name = ""; /** - * ListInstanceConfigsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * GetInstanceRequest fieldMask. + * @member {google.protobuf.IFieldMask|null|undefined} fieldMask + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @instance */ - ListInstanceConfigsResponse.prototype.nextPageToken = ""; + GetInstanceRequest.prototype.fieldMask = null; /** - * Creates a new ListInstanceConfigsResponse instance using the specified properties. + * Creates a new GetInstanceRequest instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstanceConfigsResponse=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} ListInstanceConfigsResponse instance + * @param {google.spanner.admin.instance.v1.IGetInstanceRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.GetInstanceRequest} GetInstanceRequest instance */ - ListInstanceConfigsResponse.create = function create(properties) { - return new ListInstanceConfigsResponse(properties); + GetInstanceRequest.create = function create(properties) { + return new GetInstanceRequest(properties); }; /** - * Encodes the specified ListInstanceConfigsResponse message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.verify|verify} messages. + * Encodes the specified GetInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceRequest.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstanceConfigsResponse} message ListInstanceConfigsResponse message or plain object to encode + * @param {google.spanner.admin.instance.v1.IGetInstanceRequest} message GetInstanceRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ListInstanceConfigsResponse.encode = function encode(message, writer) { + GetInstanceRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.instanceConfigs != null && message.instanceConfigs.length) - for (var i = 0; i < message.instanceConfigs.length; ++i) - $root.google.spanner.admin.instance.v1.InstanceConfig.encode(message.instanceConfigs[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.fieldMask != null && Object.hasOwnProperty.call(message, "fieldMask")) + $root.google.protobuf.FieldMask.encode(message.fieldMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; /** - * Encodes the specified ListInstanceConfigsResponse message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.verify|verify} messages. + * Encodes the specified GetInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceRequest.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstanceConfigsResponse} message ListInstanceConfigsResponse message or plain object to encode + * @param {google.spanner.admin.instance.v1.IGetInstanceRequest} message GetInstanceRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ListInstanceConfigsResponse.encodeDelimited = function encodeDelimited(message, writer) { + GetInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ListInstanceConfigsResponse message from the specified reader or buffer. + * Decodes a GetInstanceRequest message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} ListInstanceConfigsResponse + * @returns {google.spanner.admin.instance.v1.GetInstanceRequest} GetInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ListInstanceConfigsResponse.decode = function decode(reader, length) { + GetInstanceRequest.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigsResponse(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.GetInstanceRequest(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - if (!(message.instanceConfigs && message.instanceConfigs.length)) - message.instanceConfigs = []; - message.instanceConfigs.push($root.google.spanner.admin.instance.v1.InstanceConfig.decode(reader, reader.uint32())); + message.name = reader.string(); break; } case 2: { - message.nextPageToken = reader.string(); + message.fieldMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); break; } default: @@ -28204,148 +30638,138 @@ }; /** - * Decodes a ListInstanceConfigsResponse message from the specified reader or buffer, length delimited. + * Decodes a GetInstanceRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} ListInstanceConfigsResponse + * @returns {google.spanner.admin.instance.v1.GetInstanceRequest} GetInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ListInstanceConfigsResponse.decodeDelimited = function decodeDelimited(reader) { + GetInstanceRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ListInstanceConfigsResponse message. + * Verifies a GetInstanceRequest message. * @function verify - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ListInstanceConfigsResponse.verify = function verify(message) { + GetInstanceRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.instanceConfigs != null && message.hasOwnProperty("instanceConfigs")) { - if (!Array.isArray(message.instanceConfigs)) - return "instanceConfigs: array expected"; - for (var i = 0; i < message.instanceConfigs.length; ++i) { - var error = $root.google.spanner.admin.instance.v1.InstanceConfig.verify(message.instanceConfigs[i]); - if (error) - return "instanceConfigs." + error; - } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.fieldMask); + if (error) + return "fieldMask." + error; } - if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) - if (!$util.isString(message.nextPageToken)) - return "nextPageToken: string expected"; return null; }; /** - * Creates a ListInstanceConfigsResponse message from a plain object. Also converts values to their respective internal types. + * Creates a GetInstanceRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse - * @static - * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} ListInstanceConfigsResponse - */ - ListInstanceConfigsResponse.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.ListInstanceConfigsResponse) - return object; - var message = new $root.google.spanner.admin.instance.v1.ListInstanceConfigsResponse(); - if (object.instanceConfigs) { - if (!Array.isArray(object.instanceConfigs)) - throw TypeError(".google.spanner.admin.instance.v1.ListInstanceConfigsResponse.instanceConfigs: array expected"); - message.instanceConfigs = []; - for (var i = 0; i < object.instanceConfigs.length; ++i) { - if (typeof object.instanceConfigs[i] !== "object") - throw TypeError(".google.spanner.admin.instance.v1.ListInstanceConfigsResponse.instanceConfigs: object expected"); - message.instanceConfigs[i] = $root.google.spanner.admin.instance.v1.InstanceConfig.fromObject(object.instanceConfigs[i]); - } + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @static + * @param {Object.} object Plain object + * @returns {google.spanner.admin.instance.v1.GetInstanceRequest} GetInstanceRequest + */ + GetInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.GetInstanceRequest) + return object; + var message = new $root.google.spanner.admin.instance.v1.GetInstanceRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.fieldMask != null) { + if (typeof object.fieldMask !== "object") + throw TypeError(".google.spanner.admin.instance.v1.GetInstanceRequest.fieldMask: object expected"); + message.fieldMask = $root.google.protobuf.FieldMask.fromObject(object.fieldMask); } - if (object.nextPageToken != null) - message.nextPageToken = String(object.nextPageToken); return message; }; /** - * Creates a plain object from a ListInstanceConfigsResponse message. Also converts values to other types if specified. + * Creates a plain object from a GetInstanceRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.ListInstanceConfigsResponse} message ListInstanceConfigsResponse + * @param {google.spanner.admin.instance.v1.GetInstanceRequest} message GetInstanceRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ListInstanceConfigsResponse.toObject = function toObject(message, options) { + GetInstanceRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) - object.instanceConfigs = []; - if (options.defaults) - object.nextPageToken = ""; - if (message.instanceConfigs && message.instanceConfigs.length) { - object.instanceConfigs = []; - for (var j = 0; j < message.instanceConfigs.length; ++j) - object.instanceConfigs[j] = $root.google.spanner.admin.instance.v1.InstanceConfig.toObject(message.instanceConfigs[j], options); + if (options.defaults) { + object.name = ""; + object.fieldMask = null; } - if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) - object.nextPageToken = message.nextPageToken; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) + object.fieldMask = $root.google.protobuf.FieldMask.toObject(message.fieldMask, options); return object; }; /** - * Converts this ListInstanceConfigsResponse to JSON. + * Converts this GetInstanceRequest to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @instance * @returns {Object.} JSON object */ - ListInstanceConfigsResponse.prototype.toJSON = function toJSON() { + GetInstanceRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for ListInstanceConfigsResponse + * Gets the default type url for GetInstanceRequest * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.ListInstanceConfigsResponse + * @memberof google.spanner.admin.instance.v1.GetInstanceRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ListInstanceConfigsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + GetInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstanceConfigsResponse"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.GetInstanceRequest"; }; - return ListInstanceConfigsResponse; + return GetInstanceRequest; })(); - v1.GetInstanceConfigRequest = (function() { + v1.CreateInstanceRequest = (function() { /** - * Properties of a GetInstanceConfigRequest. + * Properties of a CreateInstanceRequest. * @memberof google.spanner.admin.instance.v1 - * @interface IGetInstanceConfigRequest - * @property {string|null} [name] GetInstanceConfigRequest name + * @interface ICreateInstanceRequest + * @property {string|null} [parent] CreateInstanceRequest parent + * @property {string|null} [instanceId] CreateInstanceRequest instanceId + * @property {google.spanner.admin.instance.v1.IInstance|null} [instance] CreateInstanceRequest instance */ /** - * Constructs a new GetInstanceConfigRequest. + * Constructs a new CreateInstanceRequest. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents a GetInstanceConfigRequest. - * @implements IGetInstanceConfigRequest + * @classdesc Represents a CreateInstanceRequest. + * @implements ICreateInstanceRequest * @constructor - * @param {google.spanner.admin.instance.v1.IGetInstanceConfigRequest=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.ICreateInstanceRequest=} [properties] Properties to set */ - function GetInstanceConfigRequest(properties) { + function CreateInstanceRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -28353,75 +30777,103 @@ } /** - * GetInstanceConfigRequest name. - * @member {string} name - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * CreateInstanceRequest parent. + * @member {string} parent + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @instance */ - GetInstanceConfigRequest.prototype.name = ""; + CreateInstanceRequest.prototype.parent = ""; /** - * Creates a new GetInstanceConfigRequest instance using the specified properties. + * CreateInstanceRequest instanceId. + * @member {string} instanceId + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @instance + */ + CreateInstanceRequest.prototype.instanceId = ""; + + /** + * CreateInstanceRequest instance. + * @member {google.spanner.admin.instance.v1.IInstance|null|undefined} instance + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @instance + */ + CreateInstanceRequest.prototype.instance = null; + + /** + * Creates a new CreateInstanceRequest instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IGetInstanceConfigRequest=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.GetInstanceConfigRequest} GetInstanceConfigRequest instance + * @param {google.spanner.admin.instance.v1.ICreateInstanceRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.CreateInstanceRequest} CreateInstanceRequest instance */ - GetInstanceConfigRequest.create = function create(properties) { - return new GetInstanceConfigRequest(properties); + CreateInstanceRequest.create = function create(properties) { + return new CreateInstanceRequest(properties); }; /** - * Encodes the specified GetInstanceConfigRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceConfigRequest.verify|verify} messages. + * Encodes the specified CreateInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceRequest.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IGetInstanceConfigRequest} message GetInstanceConfigRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.ICreateInstanceRequest} message CreateInstanceRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GetInstanceConfigRequest.encode = function encode(message, writer) { + CreateInstanceRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && Object.hasOwnProperty.call(message, "name")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.instanceId != null && Object.hasOwnProperty.call(message, "instanceId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.instanceId); + if (message.instance != null && Object.hasOwnProperty.call(message, "instance")) + $root.google.spanner.admin.instance.v1.Instance.encode(message.instance, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; /** - * Encodes the specified GetInstanceConfigRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceConfigRequest.verify|verify} messages. + * Encodes the specified CreateInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceRequest.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IGetInstanceConfigRequest} message GetInstanceConfigRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.ICreateInstanceRequest} message CreateInstanceRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GetInstanceConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + CreateInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a GetInstanceConfigRequest message from the specified reader or buffer. + * Decodes a CreateInstanceRequest message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.GetInstanceConfigRequest} GetInstanceConfigRequest + * @returns {google.spanner.admin.instance.v1.CreateInstanceRequest} CreateInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GetInstanceConfigRequest.decode = function decode(reader, length) { + CreateInstanceRequest.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.GetInstanceConfigRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.CreateInstanceRequest(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.name = reader.string(); + message.parent = reader.string(); + break; + } + case 2: { + message.instanceId = reader.string(); + break; + } + case 3: { + message.instance = $root.google.spanner.admin.instance.v1.Instance.decode(reader, reader.uint32()); break; } default: @@ -28433,123 +30885,147 @@ }; /** - * Decodes a GetInstanceConfigRequest message from the specified reader or buffer, length delimited. + * Decodes a CreateInstanceRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.GetInstanceConfigRequest} GetInstanceConfigRequest + * @returns {google.spanner.admin.instance.v1.CreateInstanceRequest} CreateInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GetInstanceConfigRequest.decodeDelimited = function decodeDelimited(reader) { + CreateInstanceRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a GetInstanceConfigRequest message. + * Verifies a CreateInstanceRequest message. * @function verify - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - GetInstanceConfigRequest.verify = function verify(message) { + CreateInstanceRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.name != null && message.hasOwnProperty("name")) - if (!$util.isString(message.name)) - return "name: string expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.instanceId != null && message.hasOwnProperty("instanceId")) + if (!$util.isString(message.instanceId)) + return "instanceId: string expected"; + if (message.instance != null && message.hasOwnProperty("instance")) { + var error = $root.google.spanner.admin.instance.v1.Instance.verify(message.instance); + if (error) + return "instance." + error; + } return null; }; /** - * Creates a GetInstanceConfigRequest message from a plain object. Also converts values to their respective internal types. + * Creates a CreateInstanceRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.GetInstanceConfigRequest} GetInstanceConfigRequest + * @returns {google.spanner.admin.instance.v1.CreateInstanceRequest} CreateInstanceRequest */ - GetInstanceConfigRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.GetInstanceConfigRequest) + CreateInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.CreateInstanceRequest) return object; - var message = new $root.google.spanner.admin.instance.v1.GetInstanceConfigRequest(); - if (object.name != null) - message.name = String(object.name); + var message = new $root.google.spanner.admin.instance.v1.CreateInstanceRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.instanceId != null) + message.instanceId = String(object.instanceId); + if (object.instance != null) { + if (typeof object.instance !== "object") + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceRequest.instance: object expected"); + message.instance = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instance); + } return message; }; /** - * Creates a plain object from a GetInstanceConfigRequest message. Also converts values to other types if specified. + * Creates a plain object from a CreateInstanceRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.GetInstanceConfigRequest} message GetInstanceConfigRequest + * @param {google.spanner.admin.instance.v1.CreateInstanceRequest} message CreateInstanceRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - GetInstanceConfigRequest.toObject = function toObject(message, options) { + CreateInstanceRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) - object.name = ""; - if (message.name != null && message.hasOwnProperty("name")) - object.name = message.name; + if (options.defaults) { + object.parent = ""; + object.instanceId = ""; + object.instance = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.instanceId != null && message.hasOwnProperty("instanceId")) + object.instanceId = message.instanceId; + if (message.instance != null && message.hasOwnProperty("instance")) + object.instance = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instance, options); return object; }; /** - * Converts this GetInstanceConfigRequest to JSON. + * Converts this CreateInstanceRequest to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @instance * @returns {Object.} JSON object */ - GetInstanceConfigRequest.prototype.toJSON = function toJSON() { + CreateInstanceRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for GetInstanceConfigRequest + * Gets the default type url for CreateInstanceRequest * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.GetInstanceConfigRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - GetInstanceConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + CreateInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.GetInstanceConfigRequest"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.CreateInstanceRequest"; }; - return GetInstanceConfigRequest; + return CreateInstanceRequest; })(); - v1.GetInstanceRequest = (function() { + v1.ListInstancesRequest = (function() { /** - * Properties of a GetInstanceRequest. - * @memberof google.spanner.admin.instance.v1 - * @interface IGetInstanceRequest - * @property {string|null} [name] GetInstanceRequest name - * @property {google.protobuf.IFieldMask|null} [fieldMask] GetInstanceRequest fieldMask + * Properties of a ListInstancesRequest. + * @memberof google.spanner.admin.instance.v1 + * @interface IListInstancesRequest + * @property {string|null} [parent] ListInstancesRequest parent + * @property {number|null} [pageSize] ListInstancesRequest pageSize + * @property {string|null} [pageToken] ListInstancesRequest pageToken + * @property {string|null} [filter] ListInstancesRequest filter */ /** - * Constructs a new GetInstanceRequest. + * Constructs a new ListInstancesRequest. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents a GetInstanceRequest. - * @implements IGetInstanceRequest + * @classdesc Represents a ListInstancesRequest. + * @implements IListInstancesRequest * @constructor - * @param {google.spanner.admin.instance.v1.IGetInstanceRequest=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.IListInstancesRequest=} [properties] Properties to set */ - function GetInstanceRequest(properties) { + function ListInstancesRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -28557,89 +31033,117 @@ } /** - * GetInstanceRequest name. - * @member {string} name - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * ListInstancesRequest parent. + * @member {string} parent + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @instance */ - GetInstanceRequest.prototype.name = ""; + ListInstancesRequest.prototype.parent = ""; /** - * GetInstanceRequest fieldMask. - * @member {google.protobuf.IFieldMask|null|undefined} fieldMask - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * ListInstancesRequest pageSize. + * @member {number} pageSize + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @instance */ - GetInstanceRequest.prototype.fieldMask = null; + ListInstancesRequest.prototype.pageSize = 0; /** - * Creates a new GetInstanceRequest instance using the specified properties. + * ListInstancesRequest pageToken. + * @member {string} pageToken + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @instance + */ + ListInstancesRequest.prototype.pageToken = ""; + + /** + * ListInstancesRequest filter. + * @member {string} filter + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @instance + */ + ListInstancesRequest.prototype.filter = ""; + + /** + * Creates a new ListInstancesRequest instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static - * @param {google.spanner.admin.instance.v1.IGetInstanceRequest=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.GetInstanceRequest} GetInstanceRequest instance + * @param {google.spanner.admin.instance.v1.IListInstancesRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.ListInstancesRequest} ListInstancesRequest instance */ - GetInstanceRequest.create = function create(properties) { - return new GetInstanceRequest(properties); + ListInstancesRequest.create = function create(properties) { + return new ListInstancesRequest(properties); }; /** - * Encodes the specified GetInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceRequest.verify|verify} messages. + * Encodes the specified ListInstancesRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstancesRequest.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static - * @param {google.spanner.admin.instance.v1.IGetInstanceRequest} message GetInstanceRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IListInstancesRequest} message ListInstancesRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GetInstanceRequest.encode = function encode(message, writer) { + ListInstancesRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && Object.hasOwnProperty.call(message, "name")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.fieldMask != null && Object.hasOwnProperty.call(message, "fieldMask")) - $root.google.protobuf.FieldMask.encode(message.fieldMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); return writer; }; /** - * Encodes the specified GetInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.GetInstanceRequest.verify|verify} messages. + * Encodes the specified ListInstancesRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstancesRequest.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static - * @param {google.spanner.admin.instance.v1.IGetInstanceRequest} message GetInstanceRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IListInstancesRequest} message ListInstancesRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GetInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + ListInstancesRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a GetInstanceRequest message from the specified reader or buffer. + * Decodes a ListInstancesRequest message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.GetInstanceRequest} GetInstanceRequest + * @returns {google.spanner.admin.instance.v1.ListInstancesRequest} ListInstancesRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GetInstanceRequest.decode = function decode(reader, length) { + ListInstancesRequest.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.GetInstanceRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstancesRequest(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.name = reader.string(); + message.parent = reader.string(); break; } case 2: { - message.fieldMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.filter = reader.string(); break; } default: @@ -28651,138 +31155,149 @@ }; /** - * Decodes a GetInstanceRequest message from the specified reader or buffer, length delimited. + * Decodes a ListInstancesRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.GetInstanceRequest} GetInstanceRequest + * @returns {google.spanner.admin.instance.v1.ListInstancesRequest} ListInstancesRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GetInstanceRequest.decodeDelimited = function decodeDelimited(reader) { + ListInstancesRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a GetInstanceRequest message. + * Verifies a ListInstancesRequest message. * @function verify - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - GetInstanceRequest.verify = function verify(message) { + ListInstancesRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.name != null && message.hasOwnProperty("name")) - if (!$util.isString(message.name)) - return "name: string expected"; - if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) { - var error = $root.google.protobuf.FieldMask.verify(message.fieldMask); - if (error) - return "fieldMask." + error; - } + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; return null; }; /** - * Creates a GetInstanceRequest message from a plain object. Also converts values to their respective internal types. + * Creates a ListInstancesRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.GetInstanceRequest} GetInstanceRequest + * @returns {google.spanner.admin.instance.v1.ListInstancesRequest} ListInstancesRequest */ - GetInstanceRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.GetInstanceRequest) + ListInstancesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.ListInstancesRequest) return object; - var message = new $root.google.spanner.admin.instance.v1.GetInstanceRequest(); - if (object.name != null) - message.name = String(object.name); - if (object.fieldMask != null) { - if (typeof object.fieldMask !== "object") - throw TypeError(".google.spanner.admin.instance.v1.GetInstanceRequest.fieldMask: object expected"); - message.fieldMask = $root.google.protobuf.FieldMask.fromObject(object.fieldMask); - } + var message = new $root.google.spanner.admin.instance.v1.ListInstancesRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); return message; }; /** - * Creates a plain object from a GetInstanceRequest message. Also converts values to other types if specified. + * Creates a plain object from a ListInstancesRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static - * @param {google.spanner.admin.instance.v1.GetInstanceRequest} message GetInstanceRequest + * @param {google.spanner.admin.instance.v1.ListInstancesRequest} message ListInstancesRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - GetInstanceRequest.toObject = function toObject(message, options) { + ListInstancesRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.name = ""; - object.fieldMask = null; + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; } - if (message.name != null && message.hasOwnProperty("name")) - object.name = message.name; - if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) - object.fieldMask = $root.google.protobuf.FieldMask.toObject(message.fieldMask, options); + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; return object; }; /** - * Converts this GetInstanceRequest to JSON. + * Converts this ListInstancesRequest to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @instance * @returns {Object.} JSON object */ - GetInstanceRequest.prototype.toJSON = function toJSON() { + ListInstancesRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for GetInstanceRequest + * Gets the default type url for ListInstancesRequest * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.GetInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - GetInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + ListInstancesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.GetInstanceRequest"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstancesRequest"; }; - return GetInstanceRequest; + return ListInstancesRequest; })(); - v1.CreateInstanceRequest = (function() { + v1.ListInstancesResponse = (function() { /** - * Properties of a CreateInstanceRequest. + * Properties of a ListInstancesResponse. * @memberof google.spanner.admin.instance.v1 - * @interface ICreateInstanceRequest - * @property {string|null} [parent] CreateInstanceRequest parent - * @property {string|null} [instanceId] CreateInstanceRequest instanceId - * @property {google.spanner.admin.instance.v1.IInstance|null} [instance] CreateInstanceRequest instance + * @interface IListInstancesResponse + * @property {Array.|null} [instances] ListInstancesResponse instances + * @property {string|null} [nextPageToken] ListInstancesResponse nextPageToken */ /** - * Constructs a new CreateInstanceRequest. + * Constructs a new ListInstancesResponse. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents a CreateInstanceRequest. - * @implements ICreateInstanceRequest + * @classdesc Represents a ListInstancesResponse. + * @implements IListInstancesResponse * @constructor - * @param {google.spanner.admin.instance.v1.ICreateInstanceRequest=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.IListInstancesResponse=} [properties] Properties to set */ - function CreateInstanceRequest(properties) { + function ListInstancesResponse(properties) { + this.instances = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -28790,103 +31305,92 @@ } /** - * CreateInstanceRequest parent. - * @member {string} parent - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest - * @instance - */ - CreateInstanceRequest.prototype.parent = ""; - - /** - * CreateInstanceRequest instanceId. - * @member {string} instanceId - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * ListInstancesResponse instances. + * @member {Array.} instances + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @instance */ - CreateInstanceRequest.prototype.instanceId = ""; + ListInstancesResponse.prototype.instances = $util.emptyArray; /** - * CreateInstanceRequest instance. - * @member {google.spanner.admin.instance.v1.IInstance|null|undefined} instance - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * ListInstancesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @instance */ - CreateInstanceRequest.prototype.instance = null; + ListInstancesResponse.prototype.nextPageToken = ""; /** - * Creates a new CreateInstanceRequest instance using the specified properties. + * Creates a new ListInstancesResponse instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static - * @param {google.spanner.admin.instance.v1.ICreateInstanceRequest=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.CreateInstanceRequest} CreateInstanceRequest instance + * @param {google.spanner.admin.instance.v1.IListInstancesResponse=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.ListInstancesResponse} ListInstancesResponse instance */ - CreateInstanceRequest.create = function create(properties) { - return new CreateInstanceRequest(properties); + ListInstancesResponse.create = function create(properties) { + return new ListInstancesResponse(properties); }; /** - * Encodes the specified CreateInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceRequest.verify|verify} messages. + * Encodes the specified ListInstancesResponse message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstancesResponse.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static - * @param {google.spanner.admin.instance.v1.ICreateInstanceRequest} message CreateInstanceRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IListInstancesResponse} message ListInstancesResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - CreateInstanceRequest.encode = function encode(message, writer) { + ListInstancesResponse.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.instanceId != null && Object.hasOwnProperty.call(message, "instanceId")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.instanceId); - if (message.instance != null && Object.hasOwnProperty.call(message, "instance")) - $root.google.spanner.admin.instance.v1.Instance.encode(message.instance, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.instances != null && message.instances.length) + for (var i = 0; i < message.instances.length; ++i) + $root.google.spanner.admin.instance.v1.Instance.encode(message.instances[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); return writer; }; /** - * Encodes the specified CreateInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceRequest.verify|verify} messages. + * Encodes the specified ListInstancesResponse message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstancesResponse.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static - * @param {google.spanner.admin.instance.v1.ICreateInstanceRequest} message CreateInstanceRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IListInstancesResponse} message ListInstancesResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - CreateInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + ListInstancesResponse.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a CreateInstanceRequest message from the specified reader or buffer. + * Decodes a ListInstancesResponse message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.CreateInstanceRequest} CreateInstanceRequest + * @returns {google.spanner.admin.instance.v1.ListInstancesResponse} ListInstancesResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - CreateInstanceRequest.decode = function decode(reader, length) { + ListInstancesResponse.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.CreateInstanceRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstancesResponse(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.parent = reader.string(); + if (!(message.instances && message.instances.length)) + message.instances = []; + message.instances.push($root.google.spanner.admin.instance.v1.Instance.decode(reader, reader.uint32())); break; } case 2: { - message.instanceId = reader.string(); - break; - } - case 3: { - message.instance = $root.google.spanner.admin.instance.v1.Instance.decode(reader, reader.uint32()); + message.nextPageToken = reader.string(); break; } default: @@ -28898,147 +31402,149 @@ }; /** - * Decodes a CreateInstanceRequest message from the specified reader or buffer, length delimited. + * Decodes a ListInstancesResponse message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.CreateInstanceRequest} CreateInstanceRequest + * @returns {google.spanner.admin.instance.v1.ListInstancesResponse} ListInstancesResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - CreateInstanceRequest.decodeDelimited = function decodeDelimited(reader) { + ListInstancesResponse.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a CreateInstanceRequest message. + * Verifies a ListInstancesResponse message. * @function verify - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - CreateInstanceRequest.verify = function verify(message) { + ListInstancesResponse.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.parent != null && message.hasOwnProperty("parent")) - if (!$util.isString(message.parent)) - return "parent: string expected"; - if (message.instanceId != null && message.hasOwnProperty("instanceId")) - if (!$util.isString(message.instanceId)) - return "instanceId: string expected"; - if (message.instance != null && message.hasOwnProperty("instance")) { - var error = $root.google.spanner.admin.instance.v1.Instance.verify(message.instance); - if (error) - return "instance." + error; + if (message.instances != null && message.hasOwnProperty("instances")) { + if (!Array.isArray(message.instances)) + return "instances: array expected"; + for (var i = 0; i < message.instances.length; ++i) { + var error = $root.google.spanner.admin.instance.v1.Instance.verify(message.instances[i]); + if (error) + return "instances." + error; + } } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; return null; }; /** - * Creates a CreateInstanceRequest message from a plain object. Also converts values to their respective internal types. + * Creates a ListInstancesResponse message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.CreateInstanceRequest} CreateInstanceRequest + * @returns {google.spanner.admin.instance.v1.ListInstancesResponse} ListInstancesResponse */ - CreateInstanceRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.CreateInstanceRequest) + ListInstancesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.ListInstancesResponse) return object; - var message = new $root.google.spanner.admin.instance.v1.CreateInstanceRequest(); - if (object.parent != null) - message.parent = String(object.parent); - if (object.instanceId != null) - message.instanceId = String(object.instanceId); - if (object.instance != null) { - if (typeof object.instance !== "object") - throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceRequest.instance: object expected"); - message.instance = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instance); + var message = new $root.google.spanner.admin.instance.v1.ListInstancesResponse(); + if (object.instances) { + if (!Array.isArray(object.instances)) + throw TypeError(".google.spanner.admin.instance.v1.ListInstancesResponse.instances: array expected"); + message.instances = []; + for (var i = 0; i < object.instances.length; ++i) { + if (typeof object.instances[i] !== "object") + throw TypeError(".google.spanner.admin.instance.v1.ListInstancesResponse.instances: object expected"); + message.instances[i] = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instances[i]); + } } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); return message; }; /** - * Creates a plain object from a CreateInstanceRequest message. Also converts values to other types if specified. + * Creates a plain object from a ListInstancesResponse message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static - * @param {google.spanner.admin.instance.v1.CreateInstanceRequest} message CreateInstanceRequest + * @param {google.spanner.admin.instance.v1.ListInstancesResponse} message ListInstancesResponse * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - CreateInstanceRequest.toObject = function toObject(message, options) { + ListInstancesResponse.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) { - object.parent = ""; - object.instanceId = ""; - object.instance = null; + if (options.arrays || options.defaults) + object.instances = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.instances && message.instances.length) { + object.instances = []; + for (var j = 0; j < message.instances.length; ++j) + object.instances[j] = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instances[j], options); } - if (message.parent != null && message.hasOwnProperty("parent")) - object.parent = message.parent; - if (message.instanceId != null && message.hasOwnProperty("instanceId")) - object.instanceId = message.instanceId; - if (message.instance != null && message.hasOwnProperty("instance")) - object.instance = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instance, options); + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; return object; }; /** - * Converts this CreateInstanceRequest to JSON. + * Converts this ListInstancesResponse to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @instance * @returns {Object.} JSON object */ - CreateInstanceRequest.prototype.toJSON = function toJSON() { + ListInstancesResponse.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for CreateInstanceRequest + * Gets the default type url for ListInstancesResponse * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.CreateInstanceRequest + * @memberof google.spanner.admin.instance.v1.ListInstancesResponse * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - CreateInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + ListInstancesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.CreateInstanceRequest"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstancesResponse"; }; - return CreateInstanceRequest; + return ListInstancesResponse; })(); - v1.ListInstancesRequest = (function() { + v1.UpdateInstanceRequest = (function() { /** - * Properties of a ListInstancesRequest. + * Properties of an UpdateInstanceRequest. * @memberof google.spanner.admin.instance.v1 - * @interface IListInstancesRequest - * @property {string|null} [parent] ListInstancesRequest parent - * @property {number|null} [pageSize] ListInstancesRequest pageSize - * @property {string|null} [pageToken] ListInstancesRequest pageToken - * @property {string|null} [filter] ListInstancesRequest filter + * @interface IUpdateInstanceRequest + * @property {google.spanner.admin.instance.v1.IInstance|null} [instance] UpdateInstanceRequest instance + * @property {google.protobuf.IFieldMask|null} [fieldMask] UpdateInstanceRequest fieldMask */ /** - * Constructs a new ListInstancesRequest. + * Constructs a new UpdateInstanceRequest. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents a ListInstancesRequest. - * @implements IListInstancesRequest + * @classdesc Represents an UpdateInstanceRequest. + * @implements IUpdateInstanceRequest * @constructor - * @param {google.spanner.admin.instance.v1.IListInstancesRequest=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.IUpdateInstanceRequest=} [properties] Properties to set */ - function ListInstancesRequest(properties) { + function UpdateInstanceRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -29046,117 +31552,89 @@ } /** - * ListInstancesRequest parent. - * @member {string} parent - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest - * @instance - */ - ListInstancesRequest.prototype.parent = ""; - - /** - * ListInstancesRequest pageSize. - * @member {number} pageSize - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest - * @instance - */ - ListInstancesRequest.prototype.pageSize = 0; - - /** - * ListInstancesRequest pageToken. - * @member {string} pageToken - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * UpdateInstanceRequest instance. + * @member {google.spanner.admin.instance.v1.IInstance|null|undefined} instance + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @instance */ - ListInstancesRequest.prototype.pageToken = ""; + UpdateInstanceRequest.prototype.instance = null; /** - * ListInstancesRequest filter. - * @member {string} filter - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * UpdateInstanceRequest fieldMask. + * @member {google.protobuf.IFieldMask|null|undefined} fieldMask + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @instance */ - ListInstancesRequest.prototype.filter = ""; + UpdateInstanceRequest.prototype.fieldMask = null; /** - * Creates a new ListInstancesRequest instance using the specified properties. + * Creates a new UpdateInstanceRequest instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstancesRequest=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.ListInstancesRequest} ListInstancesRequest instance + * @param {google.spanner.admin.instance.v1.IUpdateInstanceRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.UpdateInstanceRequest} UpdateInstanceRequest instance */ - ListInstancesRequest.create = function create(properties) { - return new ListInstancesRequest(properties); + UpdateInstanceRequest.create = function create(properties) { + return new UpdateInstanceRequest(properties); }; /** - * Encodes the specified ListInstancesRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstancesRequest.verify|verify} messages. + * Encodes the specified UpdateInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceRequest.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstancesRequest} message ListInstancesRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IUpdateInstanceRequest} message UpdateInstanceRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ListInstancesRequest.encode = function encode(message, writer) { + UpdateInstanceRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); - if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); - if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) - writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + if (message.instance != null && Object.hasOwnProperty.call(message, "instance")) + $root.google.spanner.admin.instance.v1.Instance.encode(message.instance, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.fieldMask != null && Object.hasOwnProperty.call(message, "fieldMask")) + $root.google.protobuf.FieldMask.encode(message.fieldMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; /** - * Encodes the specified ListInstancesRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstancesRequest.verify|verify} messages. + * Encodes the specified UpdateInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceRequest.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstancesRequest} message ListInstancesRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IUpdateInstanceRequest} message UpdateInstanceRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ListInstancesRequest.encodeDelimited = function encodeDelimited(message, writer) { + UpdateInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ListInstancesRequest message from the specified reader or buffer. + * Decodes an UpdateInstanceRequest message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.ListInstancesRequest} ListInstancesRequest + * @returns {google.spanner.admin.instance.v1.UpdateInstanceRequest} UpdateInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ListInstancesRequest.decode = function decode(reader, length) { + UpdateInstanceRequest.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstancesRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.UpdateInstanceRequest(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.parent = reader.string(); + message.instance = $root.google.spanner.admin.instance.v1.Instance.decode(reader, reader.uint32()); break; } case 2: { - message.pageSize = reader.int32(); - break; - } - case 3: { - message.pageToken = reader.string(); - break; - } - case 4: { - message.filter = reader.string(); + message.fieldMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); break; } default: @@ -29168,149 +31646,141 @@ }; /** - * Decodes a ListInstancesRequest message from the specified reader or buffer, length delimited. + * Decodes an UpdateInstanceRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.ListInstancesRequest} ListInstancesRequest + * @returns {google.spanner.admin.instance.v1.UpdateInstanceRequest} UpdateInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ListInstancesRequest.decodeDelimited = function decodeDelimited(reader) { + UpdateInstanceRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ListInstancesRequest message. + * Verifies an UpdateInstanceRequest message. * @function verify - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ListInstancesRequest.verify = function verify(message) { + UpdateInstanceRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.parent != null && message.hasOwnProperty("parent")) - if (!$util.isString(message.parent)) - return "parent: string expected"; - if (message.pageSize != null && message.hasOwnProperty("pageSize")) - if (!$util.isInteger(message.pageSize)) - return "pageSize: integer expected"; - if (message.pageToken != null && message.hasOwnProperty("pageToken")) - if (!$util.isString(message.pageToken)) - return "pageToken: string expected"; - if (message.filter != null && message.hasOwnProperty("filter")) - if (!$util.isString(message.filter)) - return "filter: string expected"; + if (message.instance != null && message.hasOwnProperty("instance")) { + var error = $root.google.spanner.admin.instance.v1.Instance.verify(message.instance); + if (error) + return "instance." + error; + } + if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.fieldMask); + if (error) + return "fieldMask." + error; + } return null; }; /** - * Creates a ListInstancesRequest message from a plain object. Also converts values to their respective internal types. + * Creates an UpdateInstanceRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.ListInstancesRequest} ListInstancesRequest + * @returns {google.spanner.admin.instance.v1.UpdateInstanceRequest} UpdateInstanceRequest */ - ListInstancesRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.ListInstancesRequest) + UpdateInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.UpdateInstanceRequest) return object; - var message = new $root.google.spanner.admin.instance.v1.ListInstancesRequest(); - if (object.parent != null) - message.parent = String(object.parent); - if (object.pageSize != null) - message.pageSize = object.pageSize | 0; - if (object.pageToken != null) - message.pageToken = String(object.pageToken); - if (object.filter != null) - message.filter = String(object.filter); + var message = new $root.google.spanner.admin.instance.v1.UpdateInstanceRequest(); + if (object.instance != null) { + if (typeof object.instance !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceRequest.instance: object expected"); + message.instance = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instance); + } + if (object.fieldMask != null) { + if (typeof object.fieldMask !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceRequest.fieldMask: object expected"); + message.fieldMask = $root.google.protobuf.FieldMask.fromObject(object.fieldMask); + } return message; }; /** - * Creates a plain object from a ListInstancesRequest message. Also converts values to other types if specified. + * Creates a plain object from an UpdateInstanceRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.ListInstancesRequest} message ListInstancesRequest + * @param {google.spanner.admin.instance.v1.UpdateInstanceRequest} message UpdateInstanceRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ListInstancesRequest.toObject = function toObject(message, options) { + UpdateInstanceRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.parent = ""; - object.pageSize = 0; - object.pageToken = ""; - object.filter = ""; + object.instance = null; + object.fieldMask = null; } - if (message.parent != null && message.hasOwnProperty("parent")) - object.parent = message.parent; - if (message.pageSize != null && message.hasOwnProperty("pageSize")) - object.pageSize = message.pageSize; - if (message.pageToken != null && message.hasOwnProperty("pageToken")) - object.pageToken = message.pageToken; - if (message.filter != null && message.hasOwnProperty("filter")) - object.filter = message.filter; + if (message.instance != null && message.hasOwnProperty("instance")) + object.instance = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instance, options); + if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) + object.fieldMask = $root.google.protobuf.FieldMask.toObject(message.fieldMask, options); return object; }; /** - * Converts this ListInstancesRequest to JSON. + * Converts this UpdateInstanceRequest to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @instance * @returns {Object.} JSON object */ - ListInstancesRequest.prototype.toJSON = function toJSON() { + UpdateInstanceRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for ListInstancesRequest + * Gets the default type url for UpdateInstanceRequest * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.ListInstancesRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ListInstancesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + UpdateInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstancesRequest"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.UpdateInstanceRequest"; }; - return ListInstancesRequest; + return UpdateInstanceRequest; })(); - v1.ListInstancesResponse = (function() { + v1.DeleteInstanceRequest = (function() { /** - * Properties of a ListInstancesResponse. + * Properties of a DeleteInstanceRequest. * @memberof google.spanner.admin.instance.v1 - * @interface IListInstancesResponse - * @property {Array.|null} [instances] ListInstancesResponse instances - * @property {string|null} [nextPageToken] ListInstancesResponse nextPageToken + * @interface IDeleteInstanceRequest + * @property {string|null} [name] DeleteInstanceRequest name */ /** - * Constructs a new ListInstancesResponse. + * Constructs a new DeleteInstanceRequest. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents a ListInstancesResponse. - * @implements IListInstancesResponse + * @classdesc Represents a DeleteInstanceRequest. + * @implements IDeleteInstanceRequest * @constructor - * @param {google.spanner.admin.instance.v1.IListInstancesResponse=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.IDeleteInstanceRequest=} [properties] Properties to set */ - function ListInstancesResponse(properties) { - this.instances = []; + function DeleteInstanceRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -29318,92 +31788,75 @@ } /** - * ListInstancesResponse instances. - * @member {Array.} instances - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse - * @instance - */ - ListInstancesResponse.prototype.instances = $util.emptyArray; - - /** - * ListInstancesResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * DeleteInstanceRequest name. + * @member {string} name + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @instance */ - ListInstancesResponse.prototype.nextPageToken = ""; + DeleteInstanceRequest.prototype.name = ""; /** - * Creates a new ListInstancesResponse instance using the specified properties. + * Creates a new DeleteInstanceRequest instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstancesResponse=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.ListInstancesResponse} ListInstancesResponse instance + * @param {google.spanner.admin.instance.v1.IDeleteInstanceRequest=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.DeleteInstanceRequest} DeleteInstanceRequest instance */ - ListInstancesResponse.create = function create(properties) { - return new ListInstancesResponse(properties); + DeleteInstanceRequest.create = function create(properties) { + return new DeleteInstanceRequest(properties); }; /** - * Encodes the specified ListInstancesResponse message. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstancesResponse.verify|verify} messages. + * Encodes the specified DeleteInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.DeleteInstanceRequest.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstancesResponse} message ListInstancesResponse message or plain object to encode + * @param {google.spanner.admin.instance.v1.IDeleteInstanceRequest} message DeleteInstanceRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ListInstancesResponse.encode = function encode(message, writer) { + DeleteInstanceRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.instances != null && message.instances.length) - for (var i = 0; i < message.instances.length; ++i) - $root.google.spanner.admin.instance.v1.Instance.encode(message.instances[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); return writer; }; /** - * Encodes the specified ListInstancesResponse message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.ListInstancesResponse.verify|verify} messages. + * Encodes the specified DeleteInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.DeleteInstanceRequest.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.IListInstancesResponse} message ListInstancesResponse message or plain object to encode + * @param {google.spanner.admin.instance.v1.IDeleteInstanceRequest} message DeleteInstanceRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ListInstancesResponse.encodeDelimited = function encodeDelimited(message, writer) { + DeleteInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ListInstancesResponse message from the specified reader or buffer. + * Decodes a DeleteInstanceRequest message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.ListInstancesResponse} ListInstancesResponse + * @returns {google.spanner.admin.instance.v1.DeleteInstanceRequest} DeleteInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ListInstancesResponse.decode = function decode(reader, length) { + DeleteInstanceRequest.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.ListInstancesResponse(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.DeleteInstanceRequest(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - if (!(message.instances && message.instances.length)) - message.instances = []; - message.instances.push($root.google.spanner.admin.instance.v1.Instance.decode(reader, reader.uint32())); - break; - } - case 2: { - message.nextPageToken = reader.string(); + message.name = reader.string(); break; } default: @@ -29415,149 +31868,125 @@ }; /** - * Decodes a ListInstancesResponse message from the specified reader or buffer, length delimited. + * Decodes a DeleteInstanceRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.ListInstancesResponse} ListInstancesResponse + * @returns {google.spanner.admin.instance.v1.DeleteInstanceRequest} DeleteInstanceRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ListInstancesResponse.decodeDelimited = function decodeDelimited(reader) { + DeleteInstanceRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ListInstancesResponse message. + * Verifies a DeleteInstanceRequest message. * @function verify - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ListInstancesResponse.verify = function verify(message) { + DeleteInstanceRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) - return "object expected"; - if (message.instances != null && message.hasOwnProperty("instances")) { - if (!Array.isArray(message.instances)) - return "instances: array expected"; - for (var i = 0; i < message.instances.length; ++i) { - var error = $root.google.spanner.admin.instance.v1.Instance.verify(message.instances[i]); - if (error) - return "instances." + error; - } - } - if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) - if (!$util.isString(message.nextPageToken)) - return "nextPageToken: string expected"; + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; return null; }; /** - * Creates a ListInstancesResponse message from a plain object. Also converts values to their respective internal types. + * Creates a DeleteInstanceRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.ListInstancesResponse} ListInstancesResponse + * @returns {google.spanner.admin.instance.v1.DeleteInstanceRequest} DeleteInstanceRequest */ - ListInstancesResponse.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.ListInstancesResponse) + DeleteInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.DeleteInstanceRequest) return object; - var message = new $root.google.spanner.admin.instance.v1.ListInstancesResponse(); - if (object.instances) { - if (!Array.isArray(object.instances)) - throw TypeError(".google.spanner.admin.instance.v1.ListInstancesResponse.instances: array expected"); - message.instances = []; - for (var i = 0; i < object.instances.length; ++i) { - if (typeof object.instances[i] !== "object") - throw TypeError(".google.spanner.admin.instance.v1.ListInstancesResponse.instances: object expected"); - message.instances[i] = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instances[i]); - } - } - if (object.nextPageToken != null) - message.nextPageToken = String(object.nextPageToken); + var message = new $root.google.spanner.admin.instance.v1.DeleteInstanceRequest(); + if (object.name != null) + message.name = String(object.name); return message; }; /** - * Creates a plain object from a ListInstancesResponse message. Also converts values to other types if specified. + * Creates a plain object from a DeleteInstanceRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static - * @param {google.spanner.admin.instance.v1.ListInstancesResponse} message ListInstancesResponse + * @param {google.spanner.admin.instance.v1.DeleteInstanceRequest} message DeleteInstanceRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ListInstancesResponse.toObject = function toObject(message, options) { + DeleteInstanceRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) - object.instances = []; if (options.defaults) - object.nextPageToken = ""; - if (message.instances && message.instances.length) { - object.instances = []; - for (var j = 0; j < message.instances.length; ++j) - object.instances[j] = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instances[j], options); - } - if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) - object.nextPageToken = message.nextPageToken; + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; return object; }; /** - * Converts this ListInstancesResponse to JSON. + * Converts this DeleteInstanceRequest to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @instance * @returns {Object.} JSON object */ - ListInstancesResponse.prototype.toJSON = function toJSON() { + DeleteInstanceRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for ListInstancesResponse + * Gets the default type url for DeleteInstanceRequest * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.ListInstancesResponse + * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ListInstancesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + DeleteInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.ListInstancesResponse"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.DeleteInstanceRequest"; }; - return ListInstancesResponse; + return DeleteInstanceRequest; })(); - v1.UpdateInstanceRequest = (function() { + v1.CreateInstanceMetadata = (function() { /** - * Properties of an UpdateInstanceRequest. + * Properties of a CreateInstanceMetadata. * @memberof google.spanner.admin.instance.v1 - * @interface IUpdateInstanceRequest - * @property {google.spanner.admin.instance.v1.IInstance|null} [instance] UpdateInstanceRequest instance - * @property {google.protobuf.IFieldMask|null} [fieldMask] UpdateInstanceRequest fieldMask + * @interface ICreateInstanceMetadata + * @property {google.spanner.admin.instance.v1.IInstance|null} [instance] CreateInstanceMetadata instance + * @property {google.protobuf.ITimestamp|null} [startTime] CreateInstanceMetadata startTime + * @property {google.protobuf.ITimestamp|null} [cancelTime] CreateInstanceMetadata cancelTime + * @property {google.protobuf.ITimestamp|null} [endTime] CreateInstanceMetadata endTime */ /** - * Constructs a new UpdateInstanceRequest. + * Constructs a new CreateInstanceMetadata. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents an UpdateInstanceRequest. - * @implements IUpdateInstanceRequest + * @classdesc Represents a CreateInstanceMetadata. + * @implements ICreateInstanceMetadata * @constructor - * @param {google.spanner.admin.instance.v1.IUpdateInstanceRequest=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.ICreateInstanceMetadata=} [properties] Properties to set */ - function UpdateInstanceRequest(properties) { + function CreateInstanceMetadata(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -29565,80 +31994,100 @@ } /** - * UpdateInstanceRequest instance. + * CreateInstanceMetadata instance. * @member {google.spanner.admin.instance.v1.IInstance|null|undefined} instance - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @instance */ - UpdateInstanceRequest.prototype.instance = null; + CreateInstanceMetadata.prototype.instance = null; /** - * UpdateInstanceRequest fieldMask. - * @member {google.protobuf.IFieldMask|null|undefined} fieldMask - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * CreateInstanceMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @instance */ - UpdateInstanceRequest.prototype.fieldMask = null; + CreateInstanceMetadata.prototype.startTime = null; /** - * Creates a new UpdateInstanceRequest instance using the specified properties. + * CreateInstanceMetadata cancelTime. + * @member {google.protobuf.ITimestamp|null|undefined} cancelTime + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @instance + */ + CreateInstanceMetadata.prototype.cancelTime = null; + + /** + * CreateInstanceMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @instance + */ + CreateInstanceMetadata.prototype.endTime = null; + + /** + * Creates a new CreateInstanceMetadata instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static - * @param {google.spanner.admin.instance.v1.IUpdateInstanceRequest=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.UpdateInstanceRequest} UpdateInstanceRequest instance + * @param {google.spanner.admin.instance.v1.ICreateInstanceMetadata=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.CreateInstanceMetadata} CreateInstanceMetadata instance */ - UpdateInstanceRequest.create = function create(properties) { - return new UpdateInstanceRequest(properties); + CreateInstanceMetadata.create = function create(properties) { + return new CreateInstanceMetadata(properties); }; /** - * Encodes the specified UpdateInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceRequest.verify|verify} messages. + * Encodes the specified CreateInstanceMetadata message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceMetadata.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static - * @param {google.spanner.admin.instance.v1.IUpdateInstanceRequest} message UpdateInstanceRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.ICreateInstanceMetadata} message CreateInstanceMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - UpdateInstanceRequest.encode = function encode(message, writer) { + CreateInstanceMetadata.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.instance != null && Object.hasOwnProperty.call(message, "instance")) $root.google.spanner.admin.instance.v1.Instance.encode(message.instance, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.fieldMask != null && Object.hasOwnProperty.call(message, "fieldMask")) - $root.google.protobuf.FieldMask.encode(message.fieldMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.startTime != null && Object.hasOwnProperty.call(message, "startTime")) + $root.google.protobuf.Timestamp.encode(message.startTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.cancelTime != null && Object.hasOwnProperty.call(message, "cancelTime")) + $root.google.protobuf.Timestamp.encode(message.cancelTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.endTime != null && Object.hasOwnProperty.call(message, "endTime")) + $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; /** - * Encodes the specified UpdateInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceRequest.verify|verify} messages. + * Encodes the specified CreateInstanceMetadata message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceMetadata.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static - * @param {google.spanner.admin.instance.v1.IUpdateInstanceRequest} message UpdateInstanceRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.ICreateInstanceMetadata} message CreateInstanceMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - UpdateInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + CreateInstanceMetadata.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes an UpdateInstanceRequest message from the specified reader or buffer. + * Decodes a CreateInstanceMetadata message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.UpdateInstanceRequest} UpdateInstanceRequest + * @returns {google.spanner.admin.instance.v1.CreateInstanceMetadata} CreateInstanceMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - UpdateInstanceRequest.decode = function decode(reader, length) { + CreateInstanceMetadata.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.UpdateInstanceRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.CreateInstanceMetadata(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { @@ -29647,7 +32096,15 @@ break; } case 2: { - message.fieldMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + message.startTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.cancelTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); break; } default: @@ -29659,30 +32116,30 @@ }; /** - * Decodes an UpdateInstanceRequest message from the specified reader or buffer, length delimited. + * Decodes a CreateInstanceMetadata message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.UpdateInstanceRequest} UpdateInstanceRequest + * @returns {google.spanner.admin.instance.v1.CreateInstanceMetadata} CreateInstanceMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - UpdateInstanceRequest.decodeDelimited = function decodeDelimited(reader) { + CreateInstanceMetadata.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies an UpdateInstanceRequest message. + * Verifies a CreateInstanceMetadata message. * @function verify - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - UpdateInstanceRequest.verify = function verify(message) { + CreateInstanceMetadata.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.instance != null && message.hasOwnProperty("instance")) { @@ -29690,110 +32147,139 @@ if (error) return "instance." + error; } - if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) { - var error = $root.google.protobuf.FieldMask.verify(message.fieldMask); + if (message.startTime != null && message.hasOwnProperty("startTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.startTime); if (error) - return "fieldMask." + error; + return "startTime." + error; + } + if (message.cancelTime != null && message.hasOwnProperty("cancelTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.cancelTime); + if (error) + return "cancelTime." + error; + } + if (message.endTime != null && message.hasOwnProperty("endTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.endTime); + if (error) + return "endTime." + error; } return null; }; /** - * Creates an UpdateInstanceRequest message from a plain object. Also converts values to their respective internal types. + * Creates a CreateInstanceMetadata message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.UpdateInstanceRequest} UpdateInstanceRequest + * @returns {google.spanner.admin.instance.v1.CreateInstanceMetadata} CreateInstanceMetadata */ - UpdateInstanceRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.UpdateInstanceRequest) + CreateInstanceMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.CreateInstanceMetadata) return object; - var message = new $root.google.spanner.admin.instance.v1.UpdateInstanceRequest(); + var message = new $root.google.spanner.admin.instance.v1.CreateInstanceMetadata(); if (object.instance != null) { if (typeof object.instance !== "object") - throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceRequest.instance: object expected"); + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceMetadata.instance: object expected"); message.instance = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instance); } - if (object.fieldMask != null) { - if (typeof object.fieldMask !== "object") - throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceRequest.fieldMask: object expected"); - message.fieldMask = $root.google.protobuf.FieldMask.fromObject(object.fieldMask); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceMetadata.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.cancelTime != null) { + if (typeof object.cancelTime !== "object") + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceMetadata.cancelTime: object expected"); + message.cancelTime = $root.google.protobuf.Timestamp.fromObject(object.cancelTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceMetadata.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); } return message; }; /** - * Creates a plain object from an UpdateInstanceRequest message. Also converts values to other types if specified. + * Creates a plain object from a CreateInstanceMetadata message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static - * @param {google.spanner.admin.instance.v1.UpdateInstanceRequest} message UpdateInstanceRequest + * @param {google.spanner.admin.instance.v1.CreateInstanceMetadata} message CreateInstanceMetadata * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - UpdateInstanceRequest.toObject = function toObject(message, options) { + CreateInstanceMetadata.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.instance = null; - object.fieldMask = null; + object.startTime = null; + object.cancelTime = null; + object.endTime = null; } if (message.instance != null && message.hasOwnProperty("instance")) object.instance = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instance, options); - if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) - object.fieldMask = $root.google.protobuf.FieldMask.toObject(message.fieldMask, options); + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.cancelTime != null && message.hasOwnProperty("cancelTime")) + object.cancelTime = $root.google.protobuf.Timestamp.toObject(message.cancelTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); return object; }; /** - * Converts this UpdateInstanceRequest to JSON. + * Converts this CreateInstanceMetadata to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @instance * @returns {Object.} JSON object */ - UpdateInstanceRequest.prototype.toJSON = function toJSON() { + CreateInstanceMetadata.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for UpdateInstanceRequest + * Gets the default type url for CreateInstanceMetadata * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.UpdateInstanceRequest + * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - UpdateInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + CreateInstanceMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.UpdateInstanceRequest"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.CreateInstanceMetadata"; }; - return UpdateInstanceRequest; + return CreateInstanceMetadata; })(); - v1.DeleteInstanceRequest = (function() { + v1.UpdateInstanceMetadata = (function() { /** - * Properties of a DeleteInstanceRequest. + * Properties of an UpdateInstanceMetadata. * @memberof google.spanner.admin.instance.v1 - * @interface IDeleteInstanceRequest - * @property {string|null} [name] DeleteInstanceRequest name + * @interface IUpdateInstanceMetadata + * @property {google.spanner.admin.instance.v1.IInstance|null} [instance] UpdateInstanceMetadata instance + * @property {google.protobuf.ITimestamp|null} [startTime] UpdateInstanceMetadata startTime + * @property {google.protobuf.ITimestamp|null} [cancelTime] UpdateInstanceMetadata cancelTime + * @property {google.protobuf.ITimestamp|null} [endTime] UpdateInstanceMetadata endTime */ /** - * Constructs a new DeleteInstanceRequest. + * Constructs a new UpdateInstanceMetadata. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents a DeleteInstanceRequest. - * @implements IDeleteInstanceRequest + * @classdesc Represents an UpdateInstanceMetadata. + * @implements IUpdateInstanceMetadata * @constructor - * @param {google.spanner.admin.instance.v1.IDeleteInstanceRequest=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.IUpdateInstanceMetadata=} [properties] Properties to set */ - function DeleteInstanceRequest(properties) { + function UpdateInstanceMetadata(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -29801,75 +32287,117 @@ } /** - * DeleteInstanceRequest name. - * @member {string} name - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * UpdateInstanceMetadata instance. + * @member {google.spanner.admin.instance.v1.IInstance|null|undefined} instance + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @instance */ - DeleteInstanceRequest.prototype.name = ""; + UpdateInstanceMetadata.prototype.instance = null; /** - * Creates a new DeleteInstanceRequest instance using the specified properties. + * UpdateInstanceMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @instance + */ + UpdateInstanceMetadata.prototype.startTime = null; + + /** + * UpdateInstanceMetadata cancelTime. + * @member {google.protobuf.ITimestamp|null|undefined} cancelTime + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @instance + */ + UpdateInstanceMetadata.prototype.cancelTime = null; + + /** + * UpdateInstanceMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @instance + */ + UpdateInstanceMetadata.prototype.endTime = null; + + /** + * Creates a new UpdateInstanceMetadata instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static - * @param {google.spanner.admin.instance.v1.IDeleteInstanceRequest=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.DeleteInstanceRequest} DeleteInstanceRequest instance + * @param {google.spanner.admin.instance.v1.IUpdateInstanceMetadata=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.UpdateInstanceMetadata} UpdateInstanceMetadata instance */ - DeleteInstanceRequest.create = function create(properties) { - return new DeleteInstanceRequest(properties); + UpdateInstanceMetadata.create = function create(properties) { + return new UpdateInstanceMetadata(properties); }; /** - * Encodes the specified DeleteInstanceRequest message. Does not implicitly {@link google.spanner.admin.instance.v1.DeleteInstanceRequest.verify|verify} messages. + * Encodes the specified UpdateInstanceMetadata message. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static - * @param {google.spanner.admin.instance.v1.IDeleteInstanceRequest} message DeleteInstanceRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IUpdateInstanceMetadata} message UpdateInstanceMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - DeleteInstanceRequest.encode = function encode(message, writer) { + UpdateInstanceMetadata.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && Object.hasOwnProperty.call(message, "name")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.instance != null && Object.hasOwnProperty.call(message, "instance")) + $root.google.spanner.admin.instance.v1.Instance.encode(message.instance, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.startTime != null && Object.hasOwnProperty.call(message, "startTime")) + $root.google.protobuf.Timestamp.encode(message.startTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.cancelTime != null && Object.hasOwnProperty.call(message, "cancelTime")) + $root.google.protobuf.Timestamp.encode(message.cancelTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.endTime != null && Object.hasOwnProperty.call(message, "endTime")) + $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; /** - * Encodes the specified DeleteInstanceRequest message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.DeleteInstanceRequest.verify|verify} messages. + * Encodes the specified UpdateInstanceMetadata message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static - * @param {google.spanner.admin.instance.v1.IDeleteInstanceRequest} message DeleteInstanceRequest message or plain object to encode + * @param {google.spanner.admin.instance.v1.IUpdateInstanceMetadata} message UpdateInstanceMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - DeleteInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + UpdateInstanceMetadata.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a DeleteInstanceRequest message from the specified reader or buffer. + * Decodes an UpdateInstanceMetadata message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.DeleteInstanceRequest} DeleteInstanceRequest + * @returns {google.spanner.admin.instance.v1.UpdateInstanceMetadata} UpdateInstanceMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - DeleteInstanceRequest.decode = function decode(reader, length) { + UpdateInstanceMetadata.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.DeleteInstanceRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.UpdateInstanceMetadata(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.name = reader.string(); + message.instance = $root.google.spanner.admin.instance.v1.Instance.decode(reader, reader.uint32()); + break; + } + case 2: { + message.startTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.cancelTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); break; } default: @@ -29881,125 +32409,169 @@ }; /** - * Decodes a DeleteInstanceRequest message from the specified reader or buffer, length delimited. + * Decodes an UpdateInstanceMetadata message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.DeleteInstanceRequest} DeleteInstanceRequest + * @returns {google.spanner.admin.instance.v1.UpdateInstanceMetadata} UpdateInstanceMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - DeleteInstanceRequest.decodeDelimited = function decodeDelimited(reader) { + UpdateInstanceMetadata.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a DeleteInstanceRequest message. + * Verifies an UpdateInstanceMetadata message. * @function verify - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - DeleteInstanceRequest.verify = function verify(message) { + UpdateInstanceMetadata.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.name != null && message.hasOwnProperty("name")) - if (!$util.isString(message.name)) - return "name: string expected"; + if (message.instance != null && message.hasOwnProperty("instance")) { + var error = $root.google.spanner.admin.instance.v1.Instance.verify(message.instance); + if (error) + return "instance." + error; + } + if (message.startTime != null && message.hasOwnProperty("startTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.startTime); + if (error) + return "startTime." + error; + } + if (message.cancelTime != null && message.hasOwnProperty("cancelTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.cancelTime); + if (error) + return "cancelTime." + error; + } + if (message.endTime != null && message.hasOwnProperty("endTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.endTime); + if (error) + return "endTime." + error; + } return null; }; /** - * Creates a DeleteInstanceRequest message from a plain object. Also converts values to their respective internal types. + * Creates an UpdateInstanceMetadata message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.DeleteInstanceRequest} DeleteInstanceRequest + * @returns {google.spanner.admin.instance.v1.UpdateInstanceMetadata} UpdateInstanceMetadata */ - DeleteInstanceRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.DeleteInstanceRequest) + UpdateInstanceMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.UpdateInstanceMetadata) return object; - var message = new $root.google.spanner.admin.instance.v1.DeleteInstanceRequest(); - if (object.name != null) - message.name = String(object.name); + var message = new $root.google.spanner.admin.instance.v1.UpdateInstanceMetadata(); + if (object.instance != null) { + if (typeof object.instance !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceMetadata.instance: object expected"); + message.instance = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instance); + } + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceMetadata.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.cancelTime != null) { + if (typeof object.cancelTime !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancelTime: object expected"); + message.cancelTime = $root.google.protobuf.Timestamp.fromObject(object.cancelTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceMetadata.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } return message; }; /** - * Creates a plain object from a DeleteInstanceRequest message. Also converts values to other types if specified. + * Creates a plain object from an UpdateInstanceMetadata message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static - * @param {google.spanner.admin.instance.v1.DeleteInstanceRequest} message DeleteInstanceRequest + * @param {google.spanner.admin.instance.v1.UpdateInstanceMetadata} message UpdateInstanceMetadata * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - DeleteInstanceRequest.toObject = function toObject(message, options) { + UpdateInstanceMetadata.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) - object.name = ""; - if (message.name != null && message.hasOwnProperty("name")) - object.name = message.name; + if (options.defaults) { + object.instance = null; + object.startTime = null; + object.cancelTime = null; + object.endTime = null; + } + if (message.instance != null && message.hasOwnProperty("instance")) + object.instance = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instance, options); + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.cancelTime != null && message.hasOwnProperty("cancelTime")) + object.cancelTime = $root.google.protobuf.Timestamp.toObject(message.cancelTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); return object; }; /** - * Converts this DeleteInstanceRequest to JSON. + * Converts this UpdateInstanceMetadata to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @instance * @returns {Object.} JSON object */ - DeleteInstanceRequest.prototype.toJSON = function toJSON() { + UpdateInstanceMetadata.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for DeleteInstanceRequest + * Gets the default type url for UpdateInstanceMetadata * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.DeleteInstanceRequest + * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - DeleteInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + UpdateInstanceMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.DeleteInstanceRequest"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.UpdateInstanceMetadata"; }; - return DeleteInstanceRequest; + return UpdateInstanceMetadata; })(); - - v1.CreateInstanceMetadata = (function() { - - /** - * Properties of a CreateInstanceMetadata. - * @memberof google.spanner.admin.instance.v1 - * @interface ICreateInstanceMetadata - * @property {google.spanner.admin.instance.v1.IInstance|null} [instance] CreateInstanceMetadata instance - * @property {google.protobuf.ITimestamp|null} [startTime] CreateInstanceMetadata startTime - * @property {google.protobuf.ITimestamp|null} [cancelTime] CreateInstanceMetadata cancelTime - * @property {google.protobuf.ITimestamp|null} [endTime] CreateInstanceMetadata endTime + + v1.CreateInstanceConfigMetadata = (function() { + + /** + * Properties of a CreateInstanceConfigMetadata. + * @memberof google.spanner.admin.instance.v1 + * @interface ICreateInstanceConfigMetadata + * @property {google.spanner.admin.instance.v1.IInstanceConfig|null} [instanceConfig] CreateInstanceConfigMetadata instanceConfig + * @property {google.spanner.admin.instance.v1.IOperationProgress|null} [progress] CreateInstanceConfigMetadata progress + * @property {google.protobuf.ITimestamp|null} [cancelTime] CreateInstanceConfigMetadata cancelTime */ /** - * Constructs a new CreateInstanceMetadata. + * Constructs a new CreateInstanceConfigMetadata. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents a CreateInstanceMetadata. - * @implements ICreateInstanceMetadata + * @classdesc Represents a CreateInstanceConfigMetadata. + * @implements ICreateInstanceConfigMetadata * @constructor - * @param {google.spanner.admin.instance.v1.ICreateInstanceMetadata=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata=} [properties] Properties to set */ - function CreateInstanceMetadata(properties) { + function CreateInstanceConfigMetadata(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -30007,119 +32579,105 @@ } /** - * CreateInstanceMetadata instance. - * @member {google.spanner.admin.instance.v1.IInstance|null|undefined} instance - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * CreateInstanceConfigMetadata instanceConfig. + * @member {google.spanner.admin.instance.v1.IInstanceConfig|null|undefined} instanceConfig + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @instance */ - CreateInstanceMetadata.prototype.instance = null; + CreateInstanceConfigMetadata.prototype.instanceConfig = null; /** - * CreateInstanceMetadata startTime. - * @member {google.protobuf.ITimestamp|null|undefined} startTime - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * CreateInstanceConfigMetadata progress. + * @member {google.spanner.admin.instance.v1.IOperationProgress|null|undefined} progress + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @instance */ - CreateInstanceMetadata.prototype.startTime = null; + CreateInstanceConfigMetadata.prototype.progress = null; /** - * CreateInstanceMetadata cancelTime. + * CreateInstanceConfigMetadata cancelTime. * @member {google.protobuf.ITimestamp|null|undefined} cancelTime - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata - * @instance - */ - CreateInstanceMetadata.prototype.cancelTime = null; - - /** - * CreateInstanceMetadata endTime. - * @member {google.protobuf.ITimestamp|null|undefined} endTime - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @instance */ - CreateInstanceMetadata.prototype.endTime = null; + CreateInstanceConfigMetadata.prototype.cancelTime = null; /** - * Creates a new CreateInstanceMetadata instance using the specified properties. + * Creates a new CreateInstanceConfigMetadata instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static - * @param {google.spanner.admin.instance.v1.ICreateInstanceMetadata=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.CreateInstanceMetadata} CreateInstanceMetadata instance + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.CreateInstanceConfigMetadata} CreateInstanceConfigMetadata instance */ - CreateInstanceMetadata.create = function create(properties) { - return new CreateInstanceMetadata(properties); + CreateInstanceConfigMetadata.create = function create(properties) { + return new CreateInstanceConfigMetadata(properties); }; /** - * Encodes the specified CreateInstanceMetadata message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceMetadata.verify|verify} messages. + * Encodes the specified CreateInstanceConfigMetadata message. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static - * @param {google.spanner.admin.instance.v1.ICreateInstanceMetadata} message CreateInstanceMetadata message or plain object to encode + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata} message CreateInstanceConfigMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - CreateInstanceMetadata.encode = function encode(message, writer) { + CreateInstanceConfigMetadata.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.instance != null && Object.hasOwnProperty.call(message, "instance")) - $root.google.spanner.admin.instance.v1.Instance.encode(message.instance, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.startTime != null && Object.hasOwnProperty.call(message, "startTime")) - $root.google.protobuf.Timestamp.encode(message.startTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.instanceConfig != null && Object.hasOwnProperty.call(message, "instanceConfig")) + $root.google.spanner.admin.instance.v1.InstanceConfig.encode(message.instanceConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.progress != null && Object.hasOwnProperty.call(message, "progress")) + $root.google.spanner.admin.instance.v1.OperationProgress.encode(message.progress, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.cancelTime != null && Object.hasOwnProperty.call(message, "cancelTime")) $root.google.protobuf.Timestamp.encode(message.cancelTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.endTime != null && Object.hasOwnProperty.call(message, "endTime")) - $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; /** - * Encodes the specified CreateInstanceMetadata message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceMetadata.verify|verify} messages. + * Encodes the specified CreateInstanceConfigMetadata message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static - * @param {google.spanner.admin.instance.v1.ICreateInstanceMetadata} message CreateInstanceMetadata message or plain object to encode + * @param {google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata} message CreateInstanceConfigMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - CreateInstanceMetadata.encodeDelimited = function encodeDelimited(message, writer) { + CreateInstanceConfigMetadata.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a CreateInstanceMetadata message from the specified reader or buffer. + * Decodes a CreateInstanceConfigMetadata message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.CreateInstanceMetadata} CreateInstanceMetadata + * @returns {google.spanner.admin.instance.v1.CreateInstanceConfigMetadata} CreateInstanceConfigMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - CreateInstanceMetadata.decode = function decode(reader, length) { + CreateInstanceConfigMetadata.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.CreateInstanceMetadata(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.CreateInstanceConfigMetadata(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.instance = $root.google.spanner.admin.instance.v1.Instance.decode(reader, reader.uint32()); + message.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.decode(reader, reader.uint32()); break; } case 2: { - message.startTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + message.progress = $root.google.spanner.admin.instance.v1.OperationProgress.decode(reader, reader.uint32()); break; } case 3: { message.cancelTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); break; } - case 4: { - message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); - break; - } default: reader.skipType(tag & 7); break; @@ -30129,170 +32687,156 @@ }; /** - * Decodes a CreateInstanceMetadata message from the specified reader or buffer, length delimited. + * Decodes a CreateInstanceConfigMetadata message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.CreateInstanceMetadata} CreateInstanceMetadata + * @returns {google.spanner.admin.instance.v1.CreateInstanceConfigMetadata} CreateInstanceConfigMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - CreateInstanceMetadata.decodeDelimited = function decodeDelimited(reader) { + CreateInstanceConfigMetadata.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a CreateInstanceMetadata message. + * Verifies a CreateInstanceConfigMetadata message. * @function verify - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - CreateInstanceMetadata.verify = function verify(message) { + CreateInstanceConfigMetadata.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.instance != null && message.hasOwnProperty("instance")) { - var error = $root.google.spanner.admin.instance.v1.Instance.verify(message.instance); + if (message.instanceConfig != null && message.hasOwnProperty("instanceConfig")) { + var error = $root.google.spanner.admin.instance.v1.InstanceConfig.verify(message.instanceConfig); if (error) - return "instance." + error; + return "instanceConfig." + error; } - if (message.startTime != null && message.hasOwnProperty("startTime")) { - var error = $root.google.protobuf.Timestamp.verify(message.startTime); + if (message.progress != null && message.hasOwnProperty("progress")) { + var error = $root.google.spanner.admin.instance.v1.OperationProgress.verify(message.progress); if (error) - return "startTime." + error; + return "progress." + error; } if (message.cancelTime != null && message.hasOwnProperty("cancelTime")) { var error = $root.google.protobuf.Timestamp.verify(message.cancelTime); if (error) return "cancelTime." + error; } - if (message.endTime != null && message.hasOwnProperty("endTime")) { - var error = $root.google.protobuf.Timestamp.verify(message.endTime); - if (error) - return "endTime." + error; - } return null; }; /** - * Creates a CreateInstanceMetadata message from a plain object. Also converts values to their respective internal types. + * Creates a CreateInstanceConfigMetadata message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.CreateInstanceMetadata} CreateInstanceMetadata + * @returns {google.spanner.admin.instance.v1.CreateInstanceConfigMetadata} CreateInstanceConfigMetadata */ - CreateInstanceMetadata.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.CreateInstanceMetadata) + CreateInstanceConfigMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) return object; - var message = new $root.google.spanner.admin.instance.v1.CreateInstanceMetadata(); - if (object.instance != null) { - if (typeof object.instance !== "object") - throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceMetadata.instance: object expected"); - message.instance = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instance); + var message = new $root.google.spanner.admin.instance.v1.CreateInstanceConfigMetadata(); + if (object.instanceConfig != null) { + if (typeof object.instanceConfig !== "object") + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceConfigMetadata.instanceConfig: object expected"); + message.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.fromObject(object.instanceConfig); } - if (object.startTime != null) { - if (typeof object.startTime !== "object") - throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceMetadata.startTime: object expected"); - message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + if (object.progress != null) { + if (typeof object.progress !== "object") + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceConfigMetadata.progress: object expected"); + message.progress = $root.google.spanner.admin.instance.v1.OperationProgress.fromObject(object.progress); } if (object.cancelTime != null) { if (typeof object.cancelTime !== "object") - throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceMetadata.cancelTime: object expected"); + throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceConfigMetadata.cancelTime: object expected"); message.cancelTime = $root.google.protobuf.Timestamp.fromObject(object.cancelTime); } - if (object.endTime != null) { - if (typeof object.endTime !== "object") - throw TypeError(".google.spanner.admin.instance.v1.CreateInstanceMetadata.endTime: object expected"); - message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); - } return message; }; /** - * Creates a plain object from a CreateInstanceMetadata message. Also converts values to other types if specified. + * Creates a plain object from a CreateInstanceConfigMetadata message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static - * @param {google.spanner.admin.instance.v1.CreateInstanceMetadata} message CreateInstanceMetadata + * @param {google.spanner.admin.instance.v1.CreateInstanceConfigMetadata} message CreateInstanceConfigMetadata * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - CreateInstanceMetadata.toObject = function toObject(message, options) { + CreateInstanceConfigMetadata.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.instance = null; - object.startTime = null; + object.instanceConfig = null; + object.progress = null; object.cancelTime = null; - object.endTime = null; } - if (message.instance != null && message.hasOwnProperty("instance")) - object.instance = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instance, options); - if (message.startTime != null && message.hasOwnProperty("startTime")) - object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.instanceConfig != null && message.hasOwnProperty("instanceConfig")) + object.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.toObject(message.instanceConfig, options); + if (message.progress != null && message.hasOwnProperty("progress")) + object.progress = $root.google.spanner.admin.instance.v1.OperationProgress.toObject(message.progress, options); if (message.cancelTime != null && message.hasOwnProperty("cancelTime")) object.cancelTime = $root.google.protobuf.Timestamp.toObject(message.cancelTime, options); - if (message.endTime != null && message.hasOwnProperty("endTime")) - object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); return object; }; /** - * Converts this CreateInstanceMetadata to JSON. + * Converts this CreateInstanceConfigMetadata to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @instance * @returns {Object.} JSON object */ - CreateInstanceMetadata.prototype.toJSON = function toJSON() { + CreateInstanceConfigMetadata.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for CreateInstanceMetadata + * Gets the default type url for CreateInstanceConfigMetadata * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.CreateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.CreateInstanceConfigMetadata * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - CreateInstanceMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + CreateInstanceConfigMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.CreateInstanceMetadata"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata"; }; - return CreateInstanceMetadata; + return CreateInstanceConfigMetadata; })(); - v1.UpdateInstanceMetadata = (function() { + v1.UpdateInstanceConfigMetadata = (function() { /** - * Properties of an UpdateInstanceMetadata. + * Properties of an UpdateInstanceConfigMetadata. * @memberof google.spanner.admin.instance.v1 - * @interface IUpdateInstanceMetadata - * @property {google.spanner.admin.instance.v1.IInstance|null} [instance] UpdateInstanceMetadata instance - * @property {google.protobuf.ITimestamp|null} [startTime] UpdateInstanceMetadata startTime - * @property {google.protobuf.ITimestamp|null} [cancelTime] UpdateInstanceMetadata cancelTime - * @property {google.protobuf.ITimestamp|null} [endTime] UpdateInstanceMetadata endTime + * @interface IUpdateInstanceConfigMetadata + * @property {google.spanner.admin.instance.v1.IInstanceConfig|null} [instanceConfig] UpdateInstanceConfigMetadata instanceConfig + * @property {google.spanner.admin.instance.v1.IOperationProgress|null} [progress] UpdateInstanceConfigMetadata progress + * @property {google.protobuf.ITimestamp|null} [cancelTime] UpdateInstanceConfigMetadata cancelTime */ /** - * Constructs a new UpdateInstanceMetadata. + * Constructs a new UpdateInstanceConfigMetadata. * @memberof google.spanner.admin.instance.v1 - * @classdesc Represents an UpdateInstanceMetadata. - * @implements IUpdateInstanceMetadata + * @classdesc Represents an UpdateInstanceConfigMetadata. + * @implements IUpdateInstanceConfigMetadata * @constructor - * @param {google.spanner.admin.instance.v1.IUpdateInstanceMetadata=} [properties] Properties to set + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata=} [properties] Properties to set */ - function UpdateInstanceMetadata(properties) { + function UpdateInstanceConfigMetadata(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -30300,119 +32844,105 @@ } /** - * UpdateInstanceMetadata instance. - * @member {google.spanner.admin.instance.v1.IInstance|null|undefined} instance - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * UpdateInstanceConfigMetadata instanceConfig. + * @member {google.spanner.admin.instance.v1.IInstanceConfig|null|undefined} instanceConfig + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @instance */ - UpdateInstanceMetadata.prototype.instance = null; + UpdateInstanceConfigMetadata.prototype.instanceConfig = null; /** - * UpdateInstanceMetadata startTime. - * @member {google.protobuf.ITimestamp|null|undefined} startTime - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * UpdateInstanceConfigMetadata progress. + * @member {google.spanner.admin.instance.v1.IOperationProgress|null|undefined} progress + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @instance */ - UpdateInstanceMetadata.prototype.startTime = null; + UpdateInstanceConfigMetadata.prototype.progress = null; /** - * UpdateInstanceMetadata cancelTime. + * UpdateInstanceConfigMetadata cancelTime. * @member {google.protobuf.ITimestamp|null|undefined} cancelTime - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata - * @instance - */ - UpdateInstanceMetadata.prototype.cancelTime = null; - - /** - * UpdateInstanceMetadata endTime. - * @member {google.protobuf.ITimestamp|null|undefined} endTime - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @instance */ - UpdateInstanceMetadata.prototype.endTime = null; + UpdateInstanceConfigMetadata.prototype.cancelTime = null; /** - * Creates a new UpdateInstanceMetadata instance using the specified properties. + * Creates a new UpdateInstanceConfigMetadata instance using the specified properties. * @function create - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static - * @param {google.spanner.admin.instance.v1.IUpdateInstanceMetadata=} [properties] Properties to set - * @returns {google.spanner.admin.instance.v1.UpdateInstanceMetadata} UpdateInstanceMetadata instance + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata=} [properties] Properties to set + * @returns {google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata} UpdateInstanceConfigMetadata instance */ - UpdateInstanceMetadata.create = function create(properties) { - return new UpdateInstanceMetadata(properties); + UpdateInstanceConfigMetadata.create = function create(properties) { + return new UpdateInstanceConfigMetadata(properties); }; /** - * Encodes the specified UpdateInstanceMetadata message. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata.verify|verify} messages. + * Encodes the specified UpdateInstanceConfigMetadata message. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.verify|verify} messages. * @function encode - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static - * @param {google.spanner.admin.instance.v1.IUpdateInstanceMetadata} message UpdateInstanceMetadata message or plain object to encode + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata} message UpdateInstanceConfigMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - UpdateInstanceMetadata.encode = function encode(message, writer) { + UpdateInstanceConfigMetadata.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.instance != null && Object.hasOwnProperty.call(message, "instance")) - $root.google.spanner.admin.instance.v1.Instance.encode(message.instance, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.startTime != null && Object.hasOwnProperty.call(message, "startTime")) - $root.google.protobuf.Timestamp.encode(message.startTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.instanceConfig != null && Object.hasOwnProperty.call(message, "instanceConfig")) + $root.google.spanner.admin.instance.v1.InstanceConfig.encode(message.instanceConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.progress != null && Object.hasOwnProperty.call(message, "progress")) + $root.google.spanner.admin.instance.v1.OperationProgress.encode(message.progress, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.cancelTime != null && Object.hasOwnProperty.call(message, "cancelTime")) $root.google.protobuf.Timestamp.encode(message.cancelTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.endTime != null && Object.hasOwnProperty.call(message, "endTime")) - $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; /** - * Encodes the specified UpdateInstanceMetadata message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata.verify|verify} messages. + * Encodes the specified UpdateInstanceConfigMetadata message, length delimited. Does not implicitly {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.verify|verify} messages. * @function encodeDelimited - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static - * @param {google.spanner.admin.instance.v1.IUpdateInstanceMetadata} message UpdateInstanceMetadata message or plain object to encode + * @param {google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata} message UpdateInstanceConfigMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - UpdateInstanceMetadata.encodeDelimited = function encodeDelimited(message, writer) { + UpdateInstanceConfigMetadata.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes an UpdateInstanceMetadata message from the specified reader or buffer. + * Decodes an UpdateInstanceConfigMetadata message from the specified reader or buffer. * @function decode - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.spanner.admin.instance.v1.UpdateInstanceMetadata} UpdateInstanceMetadata + * @returns {google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata} UpdateInstanceConfigMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - UpdateInstanceMetadata.decode = function decode(reader, length) { + UpdateInstanceConfigMetadata.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.UpdateInstanceMetadata(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.instance = $root.google.spanner.admin.instance.v1.Instance.decode(reader, reader.uint32()); + message.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.decode(reader, reader.uint32()); break; } case 2: { - message.startTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + message.progress = $root.google.spanner.admin.instance.v1.OperationProgress.decode(reader, reader.uint32()); break; } case 3: { message.cancelTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); break; } - case 4: { - message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); - break; - } default: reader.skipType(tag & 7); break; @@ -30422,147 +32952,134 @@ }; /** - * Decodes an UpdateInstanceMetadata message from the specified reader or buffer, length delimited. + * Decodes an UpdateInstanceConfigMetadata message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.spanner.admin.instance.v1.UpdateInstanceMetadata} UpdateInstanceMetadata + * @returns {google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata} UpdateInstanceConfigMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - UpdateInstanceMetadata.decodeDelimited = function decodeDelimited(reader) { + UpdateInstanceConfigMetadata.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies an UpdateInstanceMetadata message. + * Verifies an UpdateInstanceConfigMetadata message. * @function verify - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - UpdateInstanceMetadata.verify = function verify(message) { + UpdateInstanceConfigMetadata.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.instance != null && message.hasOwnProperty("instance")) { - var error = $root.google.spanner.admin.instance.v1.Instance.verify(message.instance); + if (message.instanceConfig != null && message.hasOwnProperty("instanceConfig")) { + var error = $root.google.spanner.admin.instance.v1.InstanceConfig.verify(message.instanceConfig); if (error) - return "instance." + error; + return "instanceConfig." + error; } - if (message.startTime != null && message.hasOwnProperty("startTime")) { - var error = $root.google.protobuf.Timestamp.verify(message.startTime); + if (message.progress != null && message.hasOwnProperty("progress")) { + var error = $root.google.spanner.admin.instance.v1.OperationProgress.verify(message.progress); if (error) - return "startTime." + error; + return "progress." + error; } if (message.cancelTime != null && message.hasOwnProperty("cancelTime")) { var error = $root.google.protobuf.Timestamp.verify(message.cancelTime); if (error) return "cancelTime." + error; } - if (message.endTime != null && message.hasOwnProperty("endTime")) { - var error = $root.google.protobuf.Timestamp.verify(message.endTime); - if (error) - return "endTime." + error; - } return null; }; /** - * Creates an UpdateInstanceMetadata message from a plain object. Also converts values to their respective internal types. + * Creates an UpdateInstanceConfigMetadata message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static * @param {Object.} object Plain object - * @returns {google.spanner.admin.instance.v1.UpdateInstanceMetadata} UpdateInstanceMetadata + * @returns {google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata} UpdateInstanceConfigMetadata */ - UpdateInstanceMetadata.fromObject = function fromObject(object) { - if (object instanceof $root.google.spanner.admin.instance.v1.UpdateInstanceMetadata) + UpdateInstanceConfigMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata) return object; - var message = new $root.google.spanner.admin.instance.v1.UpdateInstanceMetadata(); - if (object.instance != null) { - if (typeof object.instance !== "object") - throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceMetadata.instance: object expected"); - message.instance = $root.google.spanner.admin.instance.v1.Instance.fromObject(object.instance); + var message = new $root.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata(); + if (object.instanceConfig != null) { + if (typeof object.instanceConfig !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.instanceConfig: object expected"); + message.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.fromObject(object.instanceConfig); } - if (object.startTime != null) { - if (typeof object.startTime !== "object") - throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceMetadata.startTime: object expected"); - message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + if (object.progress != null) { + if (typeof object.progress !== "object") + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.progress: object expected"); + message.progress = $root.google.spanner.admin.instance.v1.OperationProgress.fromObject(object.progress); } if (object.cancelTime != null) { if (typeof object.cancelTime !== "object") - throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancelTime: object expected"); + throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancelTime: object expected"); message.cancelTime = $root.google.protobuf.Timestamp.fromObject(object.cancelTime); } - if (object.endTime != null) { - if (typeof object.endTime !== "object") - throw TypeError(".google.spanner.admin.instance.v1.UpdateInstanceMetadata.endTime: object expected"); - message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); - } return message; }; /** - * Creates a plain object from an UpdateInstanceMetadata message. Also converts values to other types if specified. + * Creates a plain object from an UpdateInstanceConfigMetadata message. Also converts values to other types if specified. * @function toObject - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static - * @param {google.spanner.admin.instance.v1.UpdateInstanceMetadata} message UpdateInstanceMetadata + * @param {google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata} message UpdateInstanceConfigMetadata * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - UpdateInstanceMetadata.toObject = function toObject(message, options) { + UpdateInstanceConfigMetadata.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.instance = null; - object.startTime = null; + object.instanceConfig = null; + object.progress = null; object.cancelTime = null; - object.endTime = null; } - if (message.instance != null && message.hasOwnProperty("instance")) - object.instance = $root.google.spanner.admin.instance.v1.Instance.toObject(message.instance, options); - if (message.startTime != null && message.hasOwnProperty("startTime")) - object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.instanceConfig != null && message.hasOwnProperty("instanceConfig")) + object.instanceConfig = $root.google.spanner.admin.instance.v1.InstanceConfig.toObject(message.instanceConfig, options); + if (message.progress != null && message.hasOwnProperty("progress")) + object.progress = $root.google.spanner.admin.instance.v1.OperationProgress.toObject(message.progress, options); if (message.cancelTime != null && message.hasOwnProperty("cancelTime")) object.cancelTime = $root.google.protobuf.Timestamp.toObject(message.cancelTime, options); - if (message.endTime != null && message.hasOwnProperty("endTime")) - object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); return object; }; /** - * Converts this UpdateInstanceMetadata to JSON. + * Converts this UpdateInstanceConfigMetadata to JSON. * @function toJSON - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @instance * @returns {Object.} JSON object */ - UpdateInstanceMetadata.prototype.toJSON = function toJSON() { + UpdateInstanceConfigMetadata.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for UpdateInstanceMetadata + * Gets the default type url for UpdateInstanceConfigMetadata * @function getTypeUrl - * @memberof google.spanner.admin.instance.v1.UpdateInstanceMetadata + * @memberof google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - UpdateInstanceMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + UpdateInstanceConfigMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.spanner.admin.instance.v1.UpdateInstanceMetadata"; + return typeUrlPrefix + "/google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata"; }; - return UpdateInstanceMetadata; + return UpdateInstanceConfigMetadata; })(); return v1; @@ -36668,6 +39185,7 @@ return "typeAnnotation: enum value expected"; case 0: case 2: + case 3: break; } return null; @@ -36754,6 +39272,10 @@ case 2: message.typeAnnotation = 2; break; + case "PG_JSONB": + case 3: + message.typeAnnotation = 3; + break; } return message; }; @@ -37313,11 +39835,13 @@ * @enum {number} * @property {number} TYPE_ANNOTATION_CODE_UNSPECIFIED=0 TYPE_ANNOTATION_CODE_UNSPECIFIED value * @property {number} PG_NUMERIC=2 PG_NUMERIC value + * @property {number} PG_JSONB=3 PG_JSONB value */ v1.TypeAnnotationCode = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "TYPE_ANNOTATION_CODE_UNSPECIFIED"] = 0; values[valuesById[2] = "PG_NUMERIC"] = 2; + values[valuesById[3] = "PG_JSONB"] = 3; return values; })(); diff --git a/protos/protos.json b/protos/protos.json index 68da420de..4d7348cc9 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -2720,6 +2720,22 @@ "ruby_package": "Google::Cloud::Spanner::Admin::Instance::V1" }, "nested": { + "OperationProgress": { + "fields": { + "progressPercent": { + "type": "int32", + "id": 1 + }, + "startTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + } + }, "InstanceAdmin": { "options": { "(google.api.default_host)": "spanner.googleapis.com", @@ -2762,6 +2778,98 @@ } ] }, + "CreateInstanceConfig": { + "requestType": "CreateInstanceConfigRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*}/instanceConfigs", + "(google.api.http).body": "*", + "(google.api.method_signature)": "parent,instance_config,instance_config_id", + "(google.longrunning.operation_info).response_type": "google.spanner.admin.instance.v1.InstanceConfig", + "(google.longrunning.operation_info).metadata_type": "google.spanner.admin.instance.v1.CreateInstanceConfigMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*}/instanceConfigs", + "body": "*" + } + }, + { + "(google.api.method_signature)": "parent,instance_config,instance_config_id" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.spanner.admin.instance.v1.InstanceConfig", + "metadata_type": "google.spanner.admin.instance.v1.CreateInstanceConfigMetadata" + } + } + ] + }, + "UpdateInstanceConfig": { + "requestType": "UpdateInstanceConfigRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).patch": "/v1/{instance_config.name=projects/*/instanceConfigs/*}", + "(google.api.http).body": "*", + "(google.api.method_signature)": "instance_config,update_mask", + "(google.longrunning.operation_info).response_type": "google.spanner.admin.instance.v1.InstanceConfig", + "(google.longrunning.operation_info).metadata_type": "google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v1/{instance_config.name=projects/*/instanceConfigs/*}", + "body": "*" + } + }, + { + "(google.api.method_signature)": "instance_config,update_mask" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.spanner.admin.instance.v1.InstanceConfig", + "metadata_type": "google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata" + } + } + ] + }, + "DeleteInstanceConfig": { + "requestType": "DeleteInstanceConfigRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1/{name=projects/*/instanceConfigs/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=projects/*/instanceConfigs/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListInstanceConfigOperations": { + "requestType": "ListInstanceConfigOperationsRequest", + "responseType": "ListInstanceConfigOperationsResponse", + "options": { + "(google.api.http).get": "/v1/{parent=projects/*}/instanceConfigOperations", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{parent=projects/*}/instanceConfigOperations" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, "ListInstances": { "requestType": "ListInstancesRequest", "responseType": "ListInstancesResponse", @@ -2974,15 +3082,76 @@ "type": "string", "id": 2 }, + "configType": { + "type": "Type", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, "replicas": { "rule": "repeated", "type": "ReplicaInfo", "id": 3 }, + "optionalReplicas": { + "rule": "repeated", + "type": "ReplicaInfo", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "baseConfig": { + "type": "string", + "id": 7, + "options": { + "(google.api.resource_reference).type": "spanner.googleapis.com/InstanceConfig" + } + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 8 + }, + "etag": { + "type": "string", + "id": 9 + }, "leaderOptions": { "rule": "repeated", "type": "string", "id": 4 + }, + "reconciling": { + "type": "bool", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "state": { + "type": "State", + "id": 11, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "Type": { + "values": { + "TYPE_UNSPECIFIED": 0, + "GOOGLE_MANAGED": 1, + "USER_MANAGED": 2 + } + }, + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "CREATING": 1, + "READY": 2 + } } } }, @@ -3109,6 +3278,115 @@ } } }, + "CreateInstanceConfigRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "cloudresourcemanager.googleapis.com/Project" + } + }, + "instanceConfigId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "instanceConfig": { + "type": "InstanceConfig", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "validateOnly": { + "type": "bool", + "id": 4 + } + } + }, + "UpdateInstanceConfigRequest": { + "fields": { + "instanceConfig": { + "type": "InstanceConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "validateOnly": { + "type": "bool", + "id": 3 + } + } + }, + "DeleteInstanceConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "spanner.googleapis.com/InstanceConfig" + } + }, + "etag": { + "type": "string", + "id": 2 + }, + "validateOnly": { + "type": "bool", + "id": 3 + } + } + }, + "ListInstanceConfigOperationsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "cloudresourcemanager.googleapis.com/Project" + } + }, + "filter": { + "type": "string", + "id": 2 + }, + "pageSize": { + "type": "int32", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4 + } + } + }, + "ListInstanceConfigOperationsResponse": { + "fields": { + "operations": { + "rule": "repeated", + "type": "google.longrunning.Operation", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, "GetInstanceRequest": { "fields": { "name": { @@ -3257,6 +3535,38 @@ "id": 4 } } + }, + "CreateInstanceConfigMetadata": { + "fields": { + "instanceConfig": { + "type": "InstanceConfig", + "id": 1 + }, + "progress": { + "type": "OperationProgress", + "id": 2 + }, + "cancelTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + } + }, + "UpdateInstanceConfigMetadata": { + "fields": { + "instanceConfig": { + "type": "InstanceConfig", + "id": 1 + }, + "progress": { + "type": "OperationProgress", + "id": 2 + }, + "cancelTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + } } } } @@ -3764,7 +4074,8 @@ "TypeAnnotationCode": { "values": { "TYPE_ANNOTATION_CODE_UNSPECIFIED": 0, - "PG_NUMERIC": 2 + "PG_NUMERIC": 2, + "PG_JSONB": 3 } }, "Spanner": { diff --git a/samples/package.json b/samples/package.json index b7bc4ee42..eb0420ef0 100644 --- a/samples/package.json +++ b/samples/package.json @@ -16,7 +16,7 @@ "dependencies": { "@google-cloud/kms": "^3.0.0", "@google-cloud/precise-date": "^2.0.0", - "@google-cloud/spanner": "^6.1.4", + "@google-cloud/spanner": "^6.2.0", "yargs": "^16.0.0" }, "devDependencies": { diff --git a/src/v1/database_admin_client.ts b/src/v1/database_admin_client.ts index 2cc7898be..dc72ea201 100644 --- a/src/v1/database_admin_client.ts +++ b/src/v1/database_admin_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -28,7 +28,6 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); @@ -38,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './database_admin_client_config.json'; -import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -105,8 +103,18 @@ export class DatabaseAdminClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DatabaseAdminClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DatabaseAdminClient; const servicePath = @@ -126,8 +134,13 @@ export class DatabaseAdminClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -351,7 +364,7 @@ export class DatabaseAdminClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -581,8 +594,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - name: request.name || '', + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getDatabase(request, options, callback); @@ -676,8 +689,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - database: request.database || '', + this._gaxModule.routingHeader.fromParams({ + database: request.database ?? '', }); this.initialize(); return this.innerApiCalls.dropDatabase(request, options, callback); @@ -777,8 +790,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - database: request.database || '', + this._gaxModule.routingHeader.fromParams({ + database: request.database ?? '', }); this.initialize(); return this.innerApiCalls.getDatabaseDdl(request, options, callback); @@ -878,8 +891,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - resource: request.resource || '', + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', }); this.initialize(); return this.innerApiCalls.setIamPolicy(request, options, callback); @@ -972,8 +985,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - resource: request.resource || '', + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', }); this.initialize(); return this.innerApiCalls.getIamPolicy(request, options, callback); @@ -1070,8 +1083,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - resource: request.resource || '', + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', }); this.initialize(); return this.innerApiCalls.testIamPermissions(request, options, callback); @@ -1163,8 +1176,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - name: request.name || '', + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getBackup(request, options, callback); @@ -1263,8 +1276,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - 'backup.name': request.backup!.name || '', + this._gaxModule.routingHeader.fromParams({ + 'backup.name': request.backup!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateBackup(request, options, callback); @@ -1356,8 +1369,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - name: request.name || '', + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteBackup(request, options, callback); @@ -1485,8 +1498,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createDatabase(request, options, callback); @@ -1511,11 +1524,12 @@ export class DatabaseAdminClient { protos.google.spanner.admin.database.v1.CreateDatabaseMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.createDatabase, this._gaxModule.createDefaultBackoffSettings() @@ -1650,8 +1664,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - database: request.database || '', + this._gaxModule.routingHeader.fromParams({ + database: request.database ?? '', }); this.initialize(); return this.innerApiCalls.updateDatabaseDdl(request, options, callback); @@ -1676,11 +1690,12 @@ export class DatabaseAdminClient { protos.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.updateDatabaseDdl, this._gaxModule.createDefaultBackoffSettings() @@ -1815,8 +1830,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createBackup(request, options, callback); @@ -1841,11 +1856,12 @@ export class DatabaseAdminClient { protos.google.spanner.admin.database.v1.CreateBackupMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.createBackup, this._gaxModule.createDefaultBackoffSettings() @@ -1987,8 +2003,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.copyBackup(request, options, callback); @@ -2013,11 +2029,12 @@ export class DatabaseAdminClient { protos.google.spanner.admin.database.v1.CopyBackupMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.copyBackup, this._gaxModule.createDefaultBackoffSettings() @@ -2159,8 +2176,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.restoreDatabase(request, options, callback); @@ -2185,11 +2202,12 @@ export class DatabaseAdminClient { protos.google.spanner.admin.database.v1.RestoreDatabaseMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.restoreDatabase, this._gaxModule.createDefaultBackoffSettings() @@ -2295,8 +2313,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDatabases(request, options, callback); @@ -2337,8 +2355,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatabases']; const callSettings = defaultCallSettings.merge(options); @@ -2388,8 +2406,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatabases']; const callSettings = defaultCallSettings.merge(options); @@ -2535,8 +2553,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listBackups(request, options, callback); @@ -2614,8 +2632,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); @@ -2702,8 +2720,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); @@ -2861,8 +2879,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDatabaseOperations( @@ -2951,8 +2969,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatabaseOperations']; const callSettings = defaultCallSettings.merge(options); @@ -3046,8 +3064,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatabaseOperations']; const callSettings = defaultCallSettings.merge(options); @@ -3231,8 +3249,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listBackupOperations(request, options, callback); @@ -3341,8 +3359,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listBackupOperations']; const callSettings = defaultCallSettings.merge(options); @@ -3460,8 +3478,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listBackupOperations']; const callSettings = defaultCallSettings.merge(options); @@ -3569,8 +3587,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDatabaseRoles(request, options, callback); @@ -3612,8 +3630,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatabaseRoles']; const callSettings = defaultCallSettings.merge(options); @@ -3664,8 +3682,8 @@ export class DatabaseAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatabaseRoles']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/gapic_metadata.json b/src/v1/gapic_metadata.json index 709f7759d..4a890f403 100644 --- a/src/v1/gapic_metadata.json +++ b/src/v1/gapic_metadata.json @@ -15,6 +15,11 @@ "getInstanceConfig" ] }, + "DeleteInstanceConfig": { + "methods": [ + "deleteInstanceConfig" + ] + }, "GetInstance": { "methods": [ "getInstance" @@ -40,6 +45,16 @@ "testIamPermissions" ] }, + "CreateInstanceConfig": { + "methods": [ + "createInstanceConfig" + ] + }, + "UpdateInstanceConfig": { + "methods": [ + "updateInstanceConfig" + ] + }, "CreateInstance": { "methods": [ "createInstance" @@ -57,6 +72,13 @@ "listInstanceConfigsAsync" ] }, + "ListInstanceConfigOperations": { + "methods": [ + "listInstanceConfigOperations", + "listInstanceConfigOperationsStream", + "listInstanceConfigOperationsAsync" + ] + }, "ListInstances": { "methods": [ "listInstances", @@ -74,6 +96,11 @@ "getInstanceConfig" ] }, + "DeleteInstanceConfig": { + "methods": [ + "deleteInstanceConfig" + ] + }, "GetInstance": { "methods": [ "getInstance" @@ -99,6 +126,16 @@ "testIamPermissions" ] }, + "CreateInstanceConfig": { + "methods": [ + "createInstanceConfig" + ] + }, + "UpdateInstanceConfig": { + "methods": [ + "updateInstanceConfig" + ] + }, "CreateInstance": { "methods": [ "createInstance" @@ -116,6 +153,13 @@ "listInstanceConfigsAsync" ] }, + "ListInstanceConfigOperations": { + "methods": [ + "listInstanceConfigOperations", + "listInstanceConfigOperationsStream", + "listInstanceConfigOperationsAsync" + ] + }, "ListInstances": { "methods": [ "listInstances", diff --git a/src/v1/instance_admin_client.ts b/src/v1/instance_admin_client.ts index d2eb5b89f..2213bf9ea 100644 --- a/src/v1/instance_admin_client.ts +++ b/src/v1/instance_admin_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -28,7 +28,6 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); @@ -38,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './instance_admin_client_config.json'; -import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -119,8 +117,18 @@ export class InstanceAdminClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new InstanceAdminClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof InstanceAdminClient; const servicePath = @@ -140,8 +148,13 @@ export class InstanceAdminClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -205,6 +218,11 @@ export class InstanceAdminClient { 'nextPageToken', 'instanceConfigs' ), + listInstanceConfigOperations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'operations' + ), listInstances: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -256,6 +274,18 @@ export class InstanceAdminClient { this.operationsClient = this._gaxModule .lro(lroOptions) .operationsClient(opts); + const createInstanceConfigResponse = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.InstanceConfig' + ) as gax.protobuf.Type; + const createInstanceConfigMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.CreateInstanceConfigMetadata' + ) as gax.protobuf.Type; + const updateInstanceConfigResponse = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.InstanceConfig' + ) as gax.protobuf.Type; + const updateInstanceConfigMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata' + ) as gax.protobuf.Type; const createInstanceResponse = protoFilesRoot.lookup( '.google.spanner.admin.instance.v1.Instance' ) as gax.protobuf.Type; @@ -270,6 +300,16 @@ export class InstanceAdminClient { ) as gax.protobuf.Type; this.descriptors.longrunning = { + createInstanceConfig: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceConfigResponse.decode.bind(createInstanceConfigResponse), + createInstanceConfigMetadata.decode.bind(createInstanceConfigMetadata) + ), + updateInstanceConfig: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateInstanceConfigResponse.decode.bind(updateInstanceConfigResponse), + updateInstanceConfigMetadata.decode.bind(updateInstanceConfigMetadata) + ), createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), @@ -296,7 +336,7 @@ export class InstanceAdminClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -334,6 +374,10 @@ export class InstanceAdminClient { const instanceAdminStubMethods = [ 'listInstanceConfigs', 'getInstanceConfig', + 'createInstanceConfig', + 'updateInstanceConfig', + 'deleteInstanceConfig', + 'listInstanceConfigOperations', 'listInstances', 'getInstance', 'createInstance', @@ -523,12 +567,129 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - name: request.name || '', + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getInstanceConfig(request, options, callback); } + /** + * Deletes the instance config. Deletion is only allowed when no + * instances are using the configuration. If any instances are using + * the config, returns `FAILED_PRECONDITION`. + * + * Only user managed configurations can be deleted. + * + * Authorization requires `spanner.instanceConfigs.delete` permission on + * the resource {@link google.spanner.admin.instance.v1.InstanceConfig.name|name}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the instance configuration to be deleted. + * Values are of the form + * `projects//instanceConfigs/` + * @param {string} request.etag + * Used for optimistic concurrency control as a way to help prevent + * simultaneous deletes of an instance config from overwriting each + * other. If not empty, the API + * only deletes the instance config when the etag provided matches the current + * status of the requested instance config. Otherwise, deletes the instance + * config without checking the current status of the requested instance + * config. + * @param {boolean} request.validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instance_admin.delete_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_DeleteInstanceConfig_async + */ + deleteInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest + | undefined + ), + {} | undefined + ] + >; + deleteInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstanceConfig(request, options, callback); + } /** * Gets information about a particular instance. * @@ -538,9 +699,10 @@ export class InstanceAdminClient { * Required. The name of the requested instance. Values are of the form * `projects//instances/`. * @param {google.protobuf.FieldMask} request.fieldMask - * If field_mask is present, specifies the subset of {@link google.spanner.admin.instance.v1.Instance|Instance} fields that - * should be returned. - * If absent, all {@link google.spanner.admin.instance.v1.Instance|Instance} fields are returned. + * If field_mask is present, specifies the subset of + * {@link google.spanner.admin.instance.v1.Instance|Instance} fields that should be + * returned. If absent, all + * {@link google.spanner.admin.instance.v1.Instance|Instance} fields are returned. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -619,8 +781,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - name: request.name || '', + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getInstance(request, options, callback); @@ -727,8 +889,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - name: request.name || '', + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteInstance(request, options, callback); @@ -826,8 +988,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - resource: request.resource || '', + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', }); this.initialize(); return this.innerApiCalls.setIamPolicy(request, options, callback); @@ -917,8 +1079,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - resource: request.resource || '', + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', }); this.initialize(); return this.innerApiCalls.getIamPolicy(request, options, callback); @@ -1011,13 +1173,402 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - resource: request.resource || '', + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', }); this.initialize(); return this.innerApiCalls.testIamPermissions(request, options, callback); } + /** + * Creates an instance config and begins preparing it to be used. The + * returned {@link google.longrunning.Operation|long-running operation} + * can be used to track the progress of preparing the new + * instance config. The instance config name is assigned by the caller. If the + * named instance config already exists, `CreateInstanceConfig` returns + * `ALREADY_EXISTS`. + * + * Immediately after the request returns: + * + * * The instance config is readable via the API, with all requested + * attributes. The instance config's + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} + * field is set to true. Its state is `CREATING`. + * + * While the operation is pending: + * + * * Cancelling the operation renders the instance config immediately + * unreadable via the API. + * * Except for deleting the creating resource, all other attempts to modify + * the instance config are rejected. + * + * Upon completion of the returned operation: + * + * * Instances can be created using the instance configuration. + * * The instance config's + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} + * field becomes false. Its state becomes `READY`. + * + * The returned {@link google.longrunning.Operation|long-running operation} will + * have a name of the format + * `/operations/` and can be used to track + * creation of the instance config. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. + * The {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig}, if + * successful. + * + * Authorization requires `spanner.instanceConfigs.create` permission on + * the resource + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent|parent}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to create the instance config. + * Values are of the form `projects/`. + * @param {string} request.instanceConfigId + * Required. The ID of the instance config to create. Valid identifiers are + * of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google managed configurations. + * @param {google.spanner.admin.instance.v1.InstanceConfig} request.instanceConfig + * Required. The InstanceConfig proto of the configuration to create. + * instance_config.name must be + * `/instanceConfigs/`. + * instance_config.base_config must be a Google managed configuration name, + * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + * @param {boolean} request.validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/instance_admin.create_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstanceConfig_async + */ + createInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + createInstanceConfig( + request: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createInstanceConfig( + request: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, + callback: Callback< + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstanceConfig(request, options, callback); + } + /** + * Check the status of the long running operation returned by `createInstanceConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/instance_admin.create_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstanceConfig_async + */ + async checkCreateInstanceConfigProgress( + name: string + ): Promise< + LROperation< + protos.google.spanner.admin.instance.v1.InstanceConfig, + protos.google.spanner.admin.instance.v1.CreateInstanceConfigMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInstanceConfig, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.spanner.admin.instance.v1.InstanceConfig, + protos.google.spanner.admin.instance.v1.CreateInstanceConfigMetadata + >; + } + /** + * Updates an instance config. The returned + * {@link google.longrunning.Operation|long-running operation} can be used to track + * the progress of updating the instance. If the named instance config does + * not exist, returns `NOT_FOUND`. + * + * Only user managed configurations can be updated. + * + * Immediately after the request returns: + * + * * The instance config's + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} + * field is set to true. + * + * While the operation is pending: + * + * * Cancelling the operation sets its metadata's + * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time|cancel_time}. + * The operation is guaranteed to succeed at undoing all changes, after + * which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance config are rejected. + * * Reading the instance config via the API continues to give the + * pre-request values. + * + * Upon completion of the returned operation: + * + * * Creating instances using the instance configuration uses the new + * values. + * * The instance config's new values are readable via the API. + * * The instance config's + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} + * field becomes false. + * + * The returned {@link google.longrunning.Operation|long-running operation} will + * have a name of the format + * `/operations/` and can be used to track + * the instance config modification. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata|UpdateInstanceConfigMetadata}. + * The {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig}, if + * successful. + * + * Authorization requires `spanner.instanceConfigs.update` permission on + * the resource {@link google.spanner.admin.instance.v1.InstanceConfig.name|name}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.spanner.admin.instance.v1.InstanceConfig} request.instanceConfig + * Required. The user instance config to update, which must always include the + * instance config name. Otherwise, only fields mentioned in + * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask|update_mask} + * need be included. To prevent conflicts of concurrent updates, + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|etag} can + * be used. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A mask specifying which fields in + * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig} should be + * updated. The field mask must always be specified; this prevents any future + * fields in {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig} + * from being erased accidentally by clients that do not know about them. Only + * display_name and labels can be updated. + * @param {boolean} request.validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/instance_admin.update_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstanceConfig_async + */ + updateInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + updateInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + updateInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, + callback: Callback< + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + updateInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'instance_config.name': request.instanceConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInstanceConfig(request, options, callback); + } + /** + * Check the status of the long running operation returned by `updateInstanceConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/instance_admin.update_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstanceConfig_async + */ + async checkUpdateInstanceConfigProgress( + name: string + ): Promise< + LROperation< + protos.google.spanner.admin.instance.v1.InstanceConfig, + protos.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateInstanceConfig, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.spanner.admin.instance.v1.InstanceConfig, + protos.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata + >; + } /** * Creates an instance and begins preparing it to begin serving. The * returned {@link google.longrunning.Operation|long-running operation} @@ -1156,8 +1707,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createInstance(request, options, callback); @@ -1182,11 +1733,12 @@ export class InstanceAdminClient { protos.google.spanner.admin.instance.v1.CreateInstanceMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.createInstance, this._gaxModule.createDefaultBackoffSettings() @@ -1211,9 +1763,9 @@ export class InstanceAdminClient { * Until completion of the returned operation: * * * Cancelling the operation sets its metadata's - * {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time|cancel_time}, and begins - * restoring resources to their pre-request values. The operation - * is guaranteed to succeed at undoing all resource changes, + * {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time|cancel_time}, + * and begins restoring resources to their pre-request values. The + * operation is guaranteed to succeed at undoing all resource changes, * after which point it terminates with a `CANCELLED` status. * * All other attempts to modify the instance are rejected. * * Reading the instance via the API continues to give the pre-request @@ -1242,12 +1794,15 @@ export class InstanceAdminClient { * The request object that will be sent. * @param {google.spanner.admin.instance.v1.Instance} request.instance * Required. The instance to update, which must always include the instance - * name. Otherwise, only fields mentioned in {@link google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask|field_mask} need be included. + * name. Otherwise, only fields mentioned in + * {@link google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask|field_mask} + * need be included. * @param {google.protobuf.FieldMask} request.fieldMask - * Required. A mask specifying which fields in {@link google.spanner.admin.instance.v1.Instance|Instance} should be updated. + * Required. A mask specifying which fields in + * {@link google.spanner.admin.instance.v1.Instance|Instance} should be updated. * The field mask must always be specified; this prevents any future fields in - * {@link google.spanner.admin.instance.v1.Instance|Instance} from being erased accidentally by clients that do not know - * about them. + * {@link google.spanner.admin.instance.v1.Instance|Instance} from being erased + * accidentally by clients that do not know about them. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1338,8 +1893,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - 'instance.name': request.instance!.name || '', + this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateInstance(request, options, callback); @@ -1364,11 +1919,12 @@ export class InstanceAdminClient { protos.google.spanner.admin.instance.v1.UpdateInstanceMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.updateInstance, this._gaxModule.createDefaultBackoffSettings() @@ -1393,7 +1949,8 @@ export class InstanceAdminClient { * @param {string} request.pageToken * If non-empty, `page_token` should contain a * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1475,8 +2032,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listInstanceConfigs(request, options, callback); @@ -1496,7 +2053,8 @@ export class InstanceAdminClient { * @param {string} request.pageToken * If non-empty, `page_token` should contain a * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1518,8 +2076,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listInstanceConfigs']; const callSettings = defaultCallSettings.merge(options); @@ -1547,7 +2105,8 @@ export class InstanceAdminClient { * @param {string} request.pageToken * If non-empty, `page_token` should contain a * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} @@ -1570,8 +2129,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listInstanceConfigs']; const callSettings = defaultCallSettings.merge(options); @@ -1582,6 +2141,359 @@ export class InstanceAdminClient { callSettings ) as AsyncIterable; } + /** + * Lists the user-managed instance config [long-running + * operations][google.longrunning.Operation] in the given project. An instance + * config operation has a name of the form + * `projects//instanceConfigs//operations/`. + * The long-running operation + * {@link google.longrunning.Operation.metadata|metadata} field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting + * from the most recently started operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project of the instance config operations. + * Values are of the form `projects/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. + * * The instance config name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} + * to the same `parent` and with the same `filter`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Operation]{@link google.longrunning.Operation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstanceConfigOperationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listInstanceConfigOperations( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.longrunning.IOperation[], + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest | null, + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse + ] + >; + listInstanceConfigOperations( + request: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + | protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse + | null + | undefined, + protos.google.longrunning.IOperation + > + ): void; + listInstanceConfigOperations( + request: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + callback: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + | protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse + | null + | undefined, + protos.google.longrunning.IOperation + > + ): void; + listInstanceConfigOperations( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + | protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse + | null + | undefined, + protos.google.longrunning.IOperation + >, + callback?: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + | protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse + | null + | undefined, + protos.google.longrunning.IOperation + > + ): Promise< + [ + protos.google.longrunning.IOperation[], + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest | null, + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstanceConfigOperations( + request, + options, + callback + ); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project of the instance config operations. + * Values are of the form `projects/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. + * * The instance config name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} + * to the same `parent` and with the same `filter`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Operation]{@link google.longrunning.Operation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstanceConfigOperationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listInstanceConfigOperationsStream( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listInstanceConfigOperations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstanceConfigOperations.createStream( + this.innerApiCalls.listInstanceConfigOperations as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listInstanceConfigOperations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project of the instance config operations. + * Values are of the form `projects/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. + * * The instance config name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} + * to the same `parent` and with the same `filter`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Operation]{@link google.longrunning.Operation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_admin.list_instance_config_operations.js + * region_tag:spanner_v1_generated_InstanceAdmin_ListInstanceConfigOperations_async + */ + listInstanceConfigOperationsAsync( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listInstanceConfigOperations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstanceConfigOperations.asyncIterate( + this.innerApiCalls['listInstanceConfigOperations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } /** * Lists all instances in the given project. * @@ -1595,8 +2507,9 @@ export class InstanceAdminClient { * to the server's maximum allowed page size. * @param {string} request.pageToken * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. + * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. * @param {string} request.filter * An expression for filtering the results of the request. Filter rules are * case insensitive. The fields eligible for filtering are: @@ -1698,8 +2611,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listInstances(request, options, callback); @@ -1717,8 +2630,9 @@ export class InstanceAdminClient { * to the server's maximum allowed page size. * @param {string} request.pageToken * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. + * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. * @param {string} request.filter * An expression for filtering the results of the request. Filter rules are * case insensitive. The fields eligible for filtering are: @@ -1760,8 +2674,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); @@ -1787,8 +2701,9 @@ export class InstanceAdminClient { * to the server's maximum allowed page size. * @param {string} request.pageToken * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. + * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. * @param {string} request.filter * An expression for filtering the results of the request. Filter rules are * case insensitive. The fields eligible for filtering are: @@ -1831,8 +2746,8 @@ export class InstanceAdminClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/instance_admin_client_config.json b/src/v1/instance_admin_client_config.json index bea536593..3f41e629d 100644 --- a/src/v1/instance_admin_client_config.json +++ b/src/v1/instance_admin_client_config.json @@ -39,6 +39,22 @@ "retry_codes_name": "idempotent", "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" }, + "CreateInstanceConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInstanceConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstanceConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListInstanceConfigOperations": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "ListInstances": { "timeout_millis": 3600000, "retry_codes_name": "idempotent", diff --git a/src/v1/instance_admin_proto_list.json b/src/v1/instance_admin_proto_list.json index 663d1b039..ce2400d42 100644 --- a/src/v1/instance_admin_proto_list.json +++ b/src/v1/instance_admin_proto_list.json @@ -1,3 +1,4 @@ [ + "../../protos/google/spanner/admin/instance/v1/common.proto", "../../protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto" ] diff --git a/src/v1/spanner_client.ts b/src/v1/spanner_client.ts index a6189ce24..e93060a87 100644 --- a/src/v1/spanner_client.ts +++ b/src/v1/spanner_client.ts @@ -17,19 +17,16 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, - GoogleError, } from 'google-gax'; - -import {Transform} from 'stream'; -import {PassThrough} from 'stream'; +import {Transform, PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -38,7 +35,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './spanner_client_config.json'; - const version = require('../../../package.json').version; /** @@ -101,8 +97,18 @@ export class SpannerClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SpannerClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof SpannerClient; const servicePath = @@ -122,8 +128,13 @@ export class SpannerClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -190,11 +201,11 @@ export class SpannerClient { // Provide descriptors for these. this.descriptors.stream = { executeStreamingSql: new this._gaxModule.StreamDescriptor( - gax.StreamType.SERVER_STREAMING, + this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest' ), streamingRead: new this._gaxModule.StreamDescriptor( - gax.StreamType.SERVER_STREAMING, + this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest' ), }; @@ -213,7 +224,7 @@ export class SpannerClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -275,7 +286,9 @@ export class SpannerClient { setImmediate(() => { stream.emit( 'error', - new GoogleError('The client has already been closed.') + new this._gaxModule.GoogleError( + 'The client has already been closed.' + ) ); }); return stream; @@ -458,8 +471,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - database: request.database || '', + this._gaxModule.routingHeader.fromParams({ + database: request.database ?? '', }); this.initialize(); return this.innerApiCalls.createSession(request, options, callback); @@ -552,8 +565,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - database: request.database || '', + this._gaxModule.routingHeader.fromParams({ + database: request.database ?? '', }); this.initialize(); return this.innerApiCalls.batchCreateSessions(request, options, callback); @@ -635,8 +648,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - name: request.name || '', + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getSession(request, options, callback); @@ -718,8 +731,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - name: request.name || '', + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteSession(request, options, callback); @@ -876,8 +889,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.executeSql(request, options, callback); @@ -991,8 +1004,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.executeBatchDml(request, options, callback); @@ -1127,8 +1140,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.read(request, options, callback); @@ -1219,8 +1232,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.beginTransaction(request, options, callback); @@ -1335,8 +1348,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.commit(request, options, callback); @@ -1425,8 +1438,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.rollback(request, options, callback); @@ -1554,8 +1567,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.partitionQuery(request, options, callback); @@ -1669,8 +1682,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.partitionRead(request, options, callback); @@ -1771,8 +1784,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.executeStreamingSql(request, options); @@ -1849,8 +1862,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - session: request.session || '', + this._gaxModule.routingHeader.fromParams({ + session: request.session ?? '', }); this.initialize(); return this.innerApiCalls.streamingRead(request, options); @@ -1954,8 +1967,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - database: request.database || '', + this._gaxModule.routingHeader.fromParams({ + database: request.database ?? '', }); this.initialize(); return this.innerApiCalls.listSessions(request, options, callback); @@ -2006,8 +2019,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - database: request.database || '', + this._gaxModule.routingHeader.fromParams({ + database: request.database ?? '', }); const defaultCallSettings = this._defaults['listSessions']; const callSettings = defaultCallSettings.merge(options); @@ -2065,8 +2078,8 @@ export class SpannerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - database: request.database || '', + this._gaxModule.routingHeader.fromParams({ + database: request.database ?? '', }); const defaultCallSettings = this._defaults['listSessions']; const callSettings = defaultCallSettings.merge(options); diff --git a/system-test/spanner.ts b/system-test/spanner.ts index feea97ff9..452d7c8b9 100644 --- a/system-test/spanner.ts +++ b/system-test/spanner.ts @@ -135,35 +135,41 @@ describe('Spanner', () => { }); after(async () => { - if (generateInstanceForTest) { - // Deleting all backups before an instance can be deleted. - await Promise.all( - RESOURCES_TO_CLEAN.filter(resource => resource instanceof Backup).map( - backup => backup.delete(GAX_OPTIONS) - ) - ); - /** - * Deleting instances created during this test. - * All databasess will automatically be deleted with instance. - * @see {@link https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance} - */ - await Promise.all( - RESOURCES_TO_CLEAN.filter(resource => resource instanceof Instance).map( - instance => instance.delete(GAX_OPTIONS) - ) - ); - } else { - /** - * Limit the number of concurrent 'Administrative requests per minute' - * Not to exceed quota - * @see {@link https://cloud.google.com/spanner/quotas#administrative_limits} - */ - const limit = pLimit(5); - await Promise.all( - RESOURCES_TO_CLEAN.map(resource => - limit(() => resource.delete(GAX_OPTIONS)) - ) - ); + try { + if (generateInstanceForTest) { + // Sleep for 30 seconds before cleanup, just in case + await new Promise(resolve => setTimeout(resolve, 30000)); + // Deleting all backups before an instance can be deleted. + await Promise.all( + RESOURCES_TO_CLEAN.filter(resource => resource instanceof Backup).map( + backup => backup.delete(GAX_OPTIONS) + ) + ); + /** + * Deleting instances created during this test. + * All databasess will automatically be deleted with instance. + * @see {@link https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance} + */ + await Promise.all( + RESOURCES_TO_CLEAN.filter( + resource => resource instanceof Instance + ).map(instance => instance.delete(GAX_OPTIONS)) + ); + } else { + /** + * Limit the number of concurrent 'Administrative requests per minute' + * Not to exceed quota + * @see {@link https://cloud.google.com/spanner/quotas#administrative_limits} + */ + const limit = pLimit(5); + await Promise.all( + RESOURCES_TO_CLEAN.map(resource => + limit(() => resource.delete(GAX_OPTIONS)) + ) + ); + } + } catch (err) { + console.error('Cleanup failed:', err); } }); diff --git a/test/gapic_database_admin_v1.ts b/test/gapic_database_admin_v1.ts index 94e2f9f8d..e2ec725ae 100644 --- a/test/gapic_database_admin_v1.ts +++ b/test/gapic_database_admin_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -254,26 +269,23 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.database.v1.Database() ); client.innerApiCalls.getDatabase = stubSimpleCall(expectedResponse); const [response] = await client.getDatabase(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDatabase without error using callback', async () => { @@ -285,15 +297,9 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.database.v1.Database() ); @@ -316,11 +322,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDatabase with error', async () => { @@ -332,26 +341,23 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getDatabase = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getDatabase(request), expectedError); - assert( - (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDatabase with closed client', async () => { @@ -363,7 +369,8 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetDatabaseRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getDatabase(request), expectedError); @@ -380,26 +387,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.DropDatabaseRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DropDatabaseRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.dropDatabase = stubSimpleCall(expectedResponse); const [response] = await client.dropDatabase(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.dropDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.dropDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes dropDatabase without error using callback', async () => { @@ -411,15 +417,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.DropDatabaseRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DropDatabaseRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -442,11 +444,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.dropDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.dropDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes dropDatabase with error', async () => { @@ -458,26 +463,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.DropDatabaseRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DropDatabaseRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.dropDatabase = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.dropDatabase(request), expectedError); - assert( - (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.dropDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.dropDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes dropDatabase with closed client', async () => { @@ -489,7 +493,10 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.DropDatabaseRequest() ); - request.database = ''; + const defaultValue1 = getTypeDefaultValue('DropDatabaseRequest', [ + 'database', + ]); + request.database = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.dropDatabase(request), expectedError); @@ -506,26 +513,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatabaseDdlRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseDdlResponse() ); client.innerApiCalls.getDatabaseDdl = stubSimpleCall(expectedResponse); const [response] = await client.getDatabaseDdl(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDatabaseDdl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabaseDdl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDatabaseDdl without error using callback', async () => { @@ -537,15 +543,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatabaseDdlRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseDdlResponse() ); @@ -568,11 +570,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getDatabaseDdl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabaseDdl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDatabaseDdl with error', async () => { @@ -584,26 +589,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatabaseDdlRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getDatabaseDdl = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getDatabaseDdl(request), expectedError); - assert( - (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDatabaseDdl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabaseDdl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDatabaseDdl with closed client', async () => { @@ -615,7 +619,10 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() ); - request.database = ''; + const defaultValue1 = getTypeDefaultValue('GetDatabaseDdlRequest', [ + 'database', + ]); + request.database = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getDatabaseDdl(request), expectedError); @@ -632,26 +639,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.Policy() ); client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); const [response] = await client.setIamPolicy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes setIamPolicy without error using callback', async () => { @@ -663,15 +669,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.Policy() ); @@ -694,11 +696,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes setIamPolicy with error', async () => { @@ -710,26 +715,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.setIamPolicy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.setIamPolicy(request), expectedError); - assert( - (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes setIamPolicy with closed client', async () => { @@ -741,7 +745,10 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - request.resource = ''; + const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.setIamPolicy(request), expectedError); @@ -758,26 +765,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.Policy() ); client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); const [response] = await client.getIamPolicy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIamPolicy without error using callback', async () => { @@ -789,15 +795,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.Policy() ); @@ -820,11 +822,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIamPolicy with error', async () => { @@ -836,26 +841,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getIamPolicy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getIamPolicy(request), expectedError); - assert( - (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIamPolicy with closed client', async () => { @@ -867,7 +871,10 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - request.resource = ''; + const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getIamPolicy(request), expectedError); @@ -884,15 +891,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsResponse() ); @@ -900,11 +903,14 @@ describe('v1.DatabaseAdminClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.testIamPermissions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes testIamPermissions without error using callback', async () => { @@ -916,15 +922,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsResponse() ); @@ -947,11 +949,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes testIamPermissions with error', async () => { @@ -963,26 +968,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.testIamPermissions = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.testIamPermissions(request), expectedError); - assert( - (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes testIamPermissions with closed client', async () => { @@ -994,7 +998,10 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - request.resource = ''; + const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ + 'resource', + ]); + request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.testIamPermissions(request), expectedError); @@ -1011,26 +1018,23 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetBackupRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.database.v1.Backup() ); client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); const [response] = await client.getBackup(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBackup without error using callback', async () => { @@ -1042,15 +1046,9 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetBackupRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.database.v1.Backup() ); @@ -1073,11 +1071,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBackup with error', async () => { @@ -1089,23 +1090,20 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetBackupRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getBackup(request), expectedError); - assert( - (client.innerApiCalls.getBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBackup with closed client', async () => { @@ -1117,7 +1115,8 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.GetBackupRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetBackupRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getBackup(request), expectedError); @@ -1134,27 +1133,27 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.UpdateBackupRequest() ); - request.backup = {}; - request.backup.name = ''; - const expectedHeaderRequestParams = 'backup.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateBackupRequest', [ + 'backup', + 'name', + ]); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.database.v1.Backup() ); client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); const [response] = await client.updateBackup(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateBackup without error using callback', async () => { @@ -1166,16 +1165,13 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.UpdateBackupRequest() ); - request.backup = {}; - request.backup.name = ''; - const expectedHeaderRequestParams = 'backup.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateBackupRequest', [ + 'backup', + 'name', + ]); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.database.v1.Backup() ); @@ -1198,11 +1194,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateBackup with error', async () => { @@ -1214,27 +1213,27 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.UpdateBackupRequest() ); - request.backup = {}; - request.backup.name = ''; - const expectedHeaderRequestParams = 'backup.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateBackupRequest', [ + 'backup', + 'name', + ]); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateBackup = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateBackup(request), expectedError); - assert( - (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateBackup with closed client', async () => { @@ -1246,8 +1245,12 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.UpdateBackupRequest() ); - request.backup = {}; - request.backup.name = ''; + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateBackupRequest', [ + 'backup', + 'name', + ]); + request.backup.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateBackup(request), expectedError); @@ -1264,26 +1267,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.DeleteBackupRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteBackupRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); const [response] = await client.deleteBackup(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBackup without error using callback', async () => { @@ -1295,15 +1297,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.DeleteBackupRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteBackupRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1326,11 +1324,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBackup with error', async () => { @@ -1342,26 +1343,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.DeleteBackupRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteBackupRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteBackup = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteBackup(request), expectedError); - assert( - (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBackup with closed client', async () => { @@ -1373,7 +1373,10 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.DeleteBackupRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteBackupRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteBackup(request), expectedError); @@ -1390,15 +1393,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatabaseRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1407,11 +1406,14 @@ describe('v1.DatabaseAdminClient', () => { const [operation] = await client.createDatabase(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDatabase without error using callback', async () => { @@ -1423,15 +1425,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatabaseRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1461,11 +1459,14 @@ describe('v1.DatabaseAdminClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDatabase with call error', async () => { @@ -1477,26 +1478,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatabaseRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDatabase = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createDatabase(request), expectedError); - assert( - (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDatabase with LRO error', async () => { @@ -1508,15 +1508,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatabaseRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDatabase = stubLongRunningCall( undefined, @@ -1525,11 +1521,14 @@ describe('v1.DatabaseAdminClient', () => { ); const [operation] = await client.createDatabase(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateDatabaseProgress without error', async () => { @@ -1584,15 +1583,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpdateDatabaseDdlRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1601,11 +1596,14 @@ describe('v1.DatabaseAdminClient', () => { const [operation] = await client.updateDatabaseDdl(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateDatabaseDdl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDatabaseDdl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDatabaseDdl without error using callback', async () => { @@ -1617,15 +1615,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpdateDatabaseDdlRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1655,11 +1649,14 @@ describe('v1.DatabaseAdminClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateDatabaseDdl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDatabaseDdl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDatabaseDdl with call error', async () => { @@ -1671,26 +1668,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpdateDatabaseDdlRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateDatabaseDdl = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateDatabaseDdl(request), expectedError); - assert( - (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateDatabaseDdl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDatabaseDdl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDatabaseDdl with LRO error', async () => { @@ -1702,15 +1698,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpdateDatabaseDdlRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateDatabaseDdl = stubLongRunningCall( undefined, @@ -1719,11 +1711,14 @@ describe('v1.DatabaseAdminClient', () => { ); const [operation] = await client.updateDatabaseDdl(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateDatabaseDdl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDatabaseDdl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateDatabaseDdlProgress without error', async () => { @@ -1778,15 +1773,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CreateBackupRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateBackupRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1794,11 +1785,14 @@ describe('v1.DatabaseAdminClient', () => { const [operation] = await client.createBackup(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBackup without error using callback', async () => { @@ -1810,15 +1804,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CreateBackupRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateBackupRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1848,11 +1838,14 @@ describe('v1.DatabaseAdminClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBackup with call error', async () => { @@ -1864,26 +1857,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CreateBackupRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateBackupRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createBackup = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createBackup(request), expectedError); - assert( - (client.innerApiCalls.createBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBackup with LRO error', async () => { @@ -1895,15 +1887,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CreateBackupRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateBackupRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createBackup = stubLongRunningCall( undefined, @@ -1912,11 +1900,14 @@ describe('v1.DatabaseAdminClient', () => { ); const [operation] = await client.createBackup(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateBackupProgress without error', async () => { @@ -1968,15 +1959,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CopyBackupRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CopyBackupRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1984,11 +1971,14 @@ describe('v1.DatabaseAdminClient', () => { const [operation] = await client.copyBackup(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.copyBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.copyBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes copyBackup without error using callback', async () => { @@ -2000,15 +1990,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CopyBackupRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CopyBackupRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2038,11 +2024,14 @@ describe('v1.DatabaseAdminClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.copyBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.copyBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes copyBackup with call error', async () => { @@ -2054,26 +2043,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CopyBackupRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CopyBackupRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.copyBackup = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.copyBackup(request), expectedError); - assert( - (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.copyBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.copyBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes copyBackup with LRO error', async () => { @@ -2085,15 +2073,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.CopyBackupRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CopyBackupRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.copyBackup = stubLongRunningCall( undefined, @@ -2102,11 +2086,14 @@ describe('v1.DatabaseAdminClient', () => { ); const [operation] = await client.copyBackup(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.copyBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.copyBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCopyBackupProgress without error', async () => { @@ -2158,15 +2145,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RestoreDatabaseRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2175,11 +2158,14 @@ describe('v1.DatabaseAdminClient', () => { const [operation] = await client.restoreDatabase(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.restoreDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes restoreDatabase without error using callback', async () => { @@ -2191,15 +2177,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RestoreDatabaseRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2229,11 +2211,14 @@ describe('v1.DatabaseAdminClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.restoreDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes restoreDatabase with call error', async () => { @@ -2245,26 +2230,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RestoreDatabaseRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.restoreDatabase = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.restoreDatabase(request), expectedError); - assert( - (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.restoreDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes restoreDatabase with LRO error', async () => { @@ -2276,15 +2260,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RestoreDatabaseRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.restoreDatabase = stubLongRunningCall( undefined, @@ -2293,11 +2273,14 @@ describe('v1.DatabaseAdminClient', () => { ); const [operation] = await client.restoreDatabase(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.restoreDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkRestoreDatabaseProgress without error', async () => { @@ -2352,15 +2335,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabasesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatabasesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.Database() @@ -2375,11 +2354,14 @@ describe('v1.DatabaseAdminClient', () => { client.innerApiCalls.listDatabases = stubSimpleCall(expectedResponse); const [response] = await client.listDatabases(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabases without error using callback', async () => { @@ -2391,15 +2373,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabasesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatabasesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.Database() @@ -2430,11 +2408,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabases with error', async () => { @@ -2446,26 +2427,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabasesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatabasesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDatabases = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listDatabases(request), expectedError); - assert( - (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabasesStream without error', async () => { @@ -2477,8 +2457,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabasesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatabasesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.Database() @@ -2516,11 +2499,12 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatabases, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDatabases.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2533,8 +2517,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabasesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatabasesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatabases.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2561,11 +2548,12 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatabases, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDatabases.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2578,8 +2566,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabasesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatabasesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.Database() @@ -2605,11 +2596,12 @@ describe('v1.DatabaseAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDatabases.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatabases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2622,8 +2614,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabasesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatabasesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatabases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2641,11 +2636,12 @@ describe('v1.DatabaseAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDatabases.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatabases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2660,15 +2656,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListBackupsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.Backup() @@ -2683,11 +2675,14 @@ describe('v1.DatabaseAdminClient', () => { client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); const [response] = await client.listBackups(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listBackups as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBackups without error using callback', async () => { @@ -2699,15 +2694,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListBackupsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.Backup() @@ -2738,11 +2729,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listBackups as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBackups with error', async () => { @@ -2754,26 +2748,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListBackupsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listBackups = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listBackups(request), expectedError); - assert( - (client.innerApiCalls.listBackups as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBackupsStream without error', async () => { @@ -2785,8 +2778,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListBackupsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.Backup() @@ -2823,11 +2819,12 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listBackups, request) ); - assert.strictEqual( - (client.descriptors.page.listBackups.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2840,8 +2837,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListBackupsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listBackups.createStream = stubPageStreamingCall( undefined, @@ -2869,11 +2869,12 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listBackups, request) ); - assert.strictEqual( - (client.descriptors.page.listBackups.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2886,8 +2887,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListBackupsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.Backup() @@ -2913,11 +2917,12 @@ describe('v1.DatabaseAdminClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2930,8 +2935,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListBackupsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall( undefined, @@ -2950,11 +2958,12 @@ describe('v1.DatabaseAdminClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2969,15 +2978,12 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListDatabaseOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.longrunning.Operation()), generateSampleMessage(new protos.google.longrunning.Operation()), @@ -2987,11 +2993,14 @@ describe('v1.DatabaseAdminClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listDatabaseOperations(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatabaseOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabaseOperations without error using callback', async () => { @@ -3003,15 +3012,12 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListDatabaseOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.longrunning.Operation()), generateSampleMessage(new protos.google.longrunning.Operation()), @@ -3036,11 +3042,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDatabaseOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabaseOperations with error', async () => { @@ -3052,15 +3061,12 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListDatabaseOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDatabaseOperations = stubSimpleCall( undefined, @@ -3070,11 +3076,14 @@ describe('v1.DatabaseAdminClient', () => { client.listDatabaseOperations(request), expectedError ); - assert( - (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatabaseOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabaseOperationsStream without error', async () => { @@ -3086,8 +3095,12 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListDatabaseOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.longrunning.Operation()), generateSampleMessage(new protos.google.longrunning.Operation()), @@ -3118,12 +3131,15 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatabaseOperations, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listDatabaseOperations .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3136,8 +3152,12 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListDatabaseOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatabaseOperations.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3163,12 +3183,15 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatabaseOperations, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listDatabaseOperations .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3181,8 +3204,12 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListDatabaseOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.longrunning.Operation()), generateSampleMessage(new protos.google.longrunning.Operation()), @@ -3203,12 +3230,15 @@ describe('v1.DatabaseAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listDatabaseOperations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3221,8 +3251,12 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListDatabaseOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatabaseOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3240,12 +3274,15 @@ describe('v1.DatabaseAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listDatabaseOperations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3260,15 +3297,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListBackupOperationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.longrunning.Operation()), generateSampleMessage(new protos.google.longrunning.Operation()), @@ -3278,11 +3311,14 @@ describe('v1.DatabaseAdminClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listBackupOperations(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listBackupOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBackupOperations without error using callback', async () => { @@ -3294,15 +3330,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListBackupOperationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.longrunning.Operation()), generateSampleMessage(new protos.google.longrunning.Operation()), @@ -3327,11 +3359,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listBackupOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBackupOperations with error', async () => { @@ -3343,26 +3378,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListBackupOperationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listBackupOperations = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listBackupOperations(request), expectedError); - assert( - (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listBackupOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBackupOperationsStream without error', async () => { @@ -3374,8 +3408,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListBackupOperationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.longrunning.Operation()), generateSampleMessage(new protos.google.longrunning.Operation()), @@ -3403,11 +3440,12 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listBackupOperations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listBackupOperations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listBackupOperations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3420,8 +3458,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListBackupOperationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listBackupOperations.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3444,11 +3485,12 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listBackupOperations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listBackupOperations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listBackupOperations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3461,8 +3503,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListBackupOperationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.longrunning.Operation()), generateSampleMessage(new protos.google.longrunning.Operation()), @@ -3482,11 +3527,12 @@ describe('v1.DatabaseAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listBackupOperations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3499,8 +3545,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListBackupOperationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listBackupOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3517,11 +3566,12 @@ describe('v1.DatabaseAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listBackupOperations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3536,15 +3586,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatabaseRolesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.DatabaseRole() @@ -3559,11 +3605,14 @@ describe('v1.DatabaseAdminClient', () => { client.innerApiCalls.listDatabaseRoles = stubSimpleCall(expectedResponse); const [response] = await client.listDatabaseRoles(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatabaseRoles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseRoles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabaseRoles without error using callback', async () => { @@ -3575,15 +3624,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatabaseRolesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.DatabaseRole() @@ -3616,11 +3661,14 @@ describe('v1.DatabaseAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDatabaseRoles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseRoles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabaseRoles with error', async () => { @@ -3632,26 +3680,25 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatabaseRolesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDatabaseRoles = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listDatabaseRoles(request), expectedError); - assert( - (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatabaseRoles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseRoles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatabaseRolesStream without error', async () => { @@ -3663,8 +3710,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatabaseRolesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.DatabaseRole() @@ -3702,11 +3752,12 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatabaseRoles, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDatabaseRoles.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatabaseRoles.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3719,8 +3770,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatabaseRolesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatabaseRoles.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3747,11 +3801,12 @@ describe('v1.DatabaseAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatabaseRoles, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDatabaseRoles.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatabaseRoles.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3764,8 +3819,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatabaseRolesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.database.v1.DatabaseRole() @@ -3792,11 +3850,12 @@ describe('v1.DatabaseAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3809,8 +3868,11 @@ describe('v1.DatabaseAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatabaseRolesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatabaseRoles.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3828,11 +3890,12 @@ describe('v1.DatabaseAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_instance_admin_v1.ts b/test/gapic_instance_admin_v1.ts index d56ea7348..20cabe340 100644 --- a/test/gapic_instance_admin_v1.ts +++ b/test/gapic_instance_admin_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -254,26 +269,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInstanceConfigRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.instance.v1.InstanceConfig() ); client.innerApiCalls.getInstanceConfig = stubSimpleCall(expectedResponse); const [response] = await client.getInstanceConfig(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInstanceConfig without error using callback', async () => { @@ -285,15 +299,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInstanceConfigRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.instance.v1.InstanceConfig() ); @@ -316,11 +326,14 @@ describe('v1.InstanceAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInstanceConfig with error', async () => { @@ -332,26 +345,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInstanceConfigRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getInstanceConfig = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getInstanceConfig(request), expectedError); - assert( - (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInstanceConfig with closed client', async () => { @@ -363,13 +375,143 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetInstanceConfigRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getInstanceConfig(request), expectedError); }); }); + describe('deleteInstanceConfig', () => { + it('invokes deleteInstanceConfig without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue('DeleteInstanceConfigRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteInstanceConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteInstanceConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstanceConfig without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue('DeleteInstanceConfigRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteInstanceConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstanceConfig( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstanceConfig with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue('DeleteInstanceConfigRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstanceConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteInstanceConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstanceConfig with closed client', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue('DeleteInstanceConfigRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteInstanceConfig(request), expectedError); + }); + }); + describe('getInstance', () => { it('invokes getInstance without error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ @@ -380,26 +522,23 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.GetInstanceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.instance.v1.Instance() ); client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); const [response] = await client.getInstance(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInstance without error using callback', async () => { @@ -411,15 +550,9 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.GetInstanceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.admin.instance.v1.Instance() ); @@ -442,11 +575,14 @@ describe('v1.InstanceAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInstance with error', async () => { @@ -458,26 +594,23 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.GetInstanceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getInstance = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getInstance(request), expectedError); - assert( - (client.innerApiCalls.getInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInstance with closed client', async () => { @@ -489,7 +622,8 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.GetInstanceRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetInstanceRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getInstance(request), expectedError); @@ -506,26 +640,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteInstanceRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteInstance = stubSimpleCall(expectedResponse); const [response] = await client.deleteInstance(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteInstance without error using callback', async () => { @@ -537,15 +670,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteInstanceRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -568,11 +697,14 @@ describe('v1.InstanceAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteInstance with error', async () => { @@ -584,26 +716,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteInstanceRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteInstance = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteInstance(request), expectedError); - assert( - (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteInstance with closed client', async () => { @@ -615,7 +746,10 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteInstanceRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteInstance(request), expectedError); @@ -632,26 +766,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.Policy() ); client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); const [response] = await client.setIamPolicy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes setIamPolicy without error using callback', async () => { @@ -663,15 +796,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.Policy() ); @@ -694,11 +823,14 @@ describe('v1.InstanceAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes setIamPolicy with error', async () => { @@ -710,26 +842,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.setIamPolicy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.setIamPolicy(request), expectedError); - assert( - (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes setIamPolicy with closed client', async () => { @@ -741,7 +872,10 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - request.resource = ''; + const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.setIamPolicy(request), expectedError); @@ -758,26 +892,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.Policy() ); client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); const [response] = await client.getIamPolicy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIamPolicy without error using callback', async () => { @@ -789,15 +922,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.Policy() ); @@ -820,11 +949,14 @@ describe('v1.InstanceAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIamPolicy with error', async () => { @@ -836,26 +968,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getIamPolicy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getIamPolicy(request), expectedError); - assert( - (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIamPolicy with closed client', async () => { @@ -867,7 +998,10 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - request.resource = ''; + const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ + 'resource', + ]); + request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getIamPolicy(request), expectedError); @@ -884,15 +1018,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsResponse() ); @@ -900,11 +1030,14 @@ describe('v1.InstanceAdminClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.testIamPermissions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes testIamPermissions without error using callback', async () => { @@ -916,15 +1049,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsResponse() ); @@ -947,11 +1076,14 @@ describe('v1.InstanceAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes testIamPermissions with error', async () => { @@ -963,26 +1095,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ + 'resource', + ]); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.testIamPermissions = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.testIamPermissions(request), expectedError); - assert( - (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes testIamPermissions with closed client', async () => { @@ -994,78 +1125,76 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - request.resource = ''; + const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ + 'resource', + ]); + request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.testIamPermissions(request), expectedError); }); }); - describe('createInstance', () => { - it('invokes createInstance without error', async () => { + describe('createInstanceConfig', () => { + it('invokes createInstanceConfig without error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateInstanceConfigRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.createInstance = + client.innerApiCalls.createInstanceConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); + const [operation] = await client.createInstanceConfig(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes createInstance without error using callback', async () => { + it('invokes createInstanceConfig without error using callback', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateInstanceConfigRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.createInstance = + client.innerApiCalls.createInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { - client.createInstance( + client.createInstanceConfig( request, ( err?: Error | null, result?: LROperation< - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.ICreateInstanceMetadata + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata > | null ) => { if (err) { @@ -1077,83 +1206,84 @@ describe('v1.InstanceAdminClient', () => { ); }); const operation = (await promise) as LROperation< - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.ICreateInstanceMetadata + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.ICreateInstanceConfigMetadata >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes createInstance with call error', async () => { + it('invokes createInstanceConfig with call error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateInstanceConfigRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall( + client.innerApiCalls.createInstanceConfig = stubLongRunningCall( undefined, expectedError ); - await assert.rejects(client.createInstance(request), expectedError); - assert( - (client.innerApiCalls.createInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + await assert.rejects(client.createInstanceConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes createInstance with LRO error', async () => { + it('invokes createInstanceConfig with LRO error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateInstanceConfigRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall( + client.innerApiCalls.createInstanceConfig = stubLongRunningCall( undefined, undefined, expectedError ); - const [operation] = await client.createInstance(request); + const [operation] = await client.createInstanceConfig(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes checkCreateInstanceProgress without error', async () => { + it('invokes checkCreateInstanceConfigProgress without error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -1167,7 +1297,7 @@ describe('v1.InstanceAdminClient', () => { expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateInstanceProgress( + const decodedOperation = await client.checkCreateInstanceConfigProgress( expectedResponse.name ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); @@ -1175,7 +1305,7 @@ describe('v1.InstanceAdminClient', () => { assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - it('invokes checkCreateInstanceProgress with error', async () => { + it('invokes checkCreateInstanceConfigProgress with error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -1188,80 +1318,77 @@ describe('v1.InstanceAdminClient', () => { expectedError ); await assert.rejects( - client.checkCreateInstanceProgress(''), + client.checkCreateInstanceConfigProgress(''), expectedError ); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); }); - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { + describe('updateInstanceConfig', () => { + it('invokes updateInstanceConfig without error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() - ); - request.instance = {}; - request.instance.name = ''; - const expectedHeaderRequestParams = 'instance.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() + ); + request.instanceConfig ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInstanceConfigRequest', [ + 'instanceConfig', + 'name', + ]); + request.instanceConfig.name = defaultValue1; + const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.updateInstance = + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); + const [operation] = await client.updateInstanceConfig(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes updateInstance without error using callback', async () => { + it('invokes updateInstanceConfig without error using callback', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() - ); - request.instance = {}; - request.instance.name = ''; - const expectedHeaderRequestParams = 'instance.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() + ); + request.instanceConfig ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInstanceConfigRequest', [ + 'instanceConfig', + 'name', + ]); + request.instanceConfig.name = defaultValue1; + const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.updateInstance = + client.innerApiCalls.updateInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { - client.updateInstance( + client.updateInstanceConfig( request, ( err?: Error | null, result?: LROperation< - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.IUpdateInstanceMetadata + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata > | null ) => { if (err) { @@ -1273,85 +1400,88 @@ describe('v1.InstanceAdminClient', () => { ); }); const operation = (await promise) as LROperation< - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.IUpdateInstanceMetadata + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigMetadata >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes updateInstance with call error', async () => { + it('invokes updateInstanceConfig with call error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() - ); - request.instance = {}; - request.instance.name = ''; - const expectedHeaderRequestParams = 'instance.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() + ); + request.instanceConfig ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInstanceConfigRequest', [ + 'instanceConfig', + 'name', + ]); + request.instanceConfig.name = defaultValue1; + const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall( + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall( undefined, expectedError ); - await assert.rejects(client.updateInstance(request), expectedError); - assert( - (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + await assert.rejects(client.updateInstanceConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes updateInstance with LRO error', async () => { + it('invokes updateInstanceConfig with LRO error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() - ); - request.instance = {}; - request.instance.name = ''; - const expectedHeaderRequestParams = 'instance.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() + ); + request.instanceConfig ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInstanceConfigRequest', [ + 'instanceConfig', + 'name', + ]); + request.instanceConfig.name = defaultValue1; + const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall( + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall( undefined, undefined, expectedError ); - const [operation] = await client.updateInstance(request); + const [operation] = await client.updateInstanceConfig(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes checkUpdateInstanceProgress without error', async () => { + it('invokes checkUpdateInstanceConfigProgress without error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -1365,7 +1495,7 @@ describe('v1.InstanceAdminClient', () => { expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateInstanceProgress( + const decodedOperation = await client.checkUpdateInstanceConfigProgress( expectedResponse.name ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); @@ -1373,7 +1503,7 @@ describe('v1.InstanceAdminClient', () => { assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - it('invokes checkUpdateInstanceProgress with error', async () => { + it('invokes checkUpdateInstanceConfigProgress with error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -1386,14 +1516,402 @@ describe('v1.InstanceAdminClient', () => { expectedError ); await assert.rejects( - client.checkUpdateInstanceProgress(''), + client.checkUpdateInstanceConfigProgress(''), expectedError ); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); }); - describe('listInstanceConfigs', () => { + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + ); + const defaultValue1 = getTypeDefaultValue('CreateInstanceRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + ); + const defaultValue1 = getTypeDefaultValue('CreateInstanceRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.ICreateInstanceMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.ICreateInstanceMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with call error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + ); + const defaultValue1 = getTypeDefaultValue('CreateInstanceRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with LRO error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + ); + const defaultValue1 = getTypeDefaultValue('CreateInstanceRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateInstanceProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInstanceRequest', [ + 'instance', + 'name', + ]); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInstanceRequest', [ + 'instance', + 'name', + ]); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.IUpdateInstanceMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.IUpdateInstanceMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with call error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInstanceRequest', [ + 'instance', + 'name', + ]); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with LRO error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInstanceRequest', [ + 'instance', + 'name', + ]); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateInstanceProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUpdateInstanceProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInstanceConfigs', () => { it('invokes listInstanceConfigs without error', async () => { const client = new instanceadminModule.v1.InstanceAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, @@ -1403,15 +1921,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInstanceConfigsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.instance.v1.InstanceConfig() @@ -1427,11 +1941,14 @@ describe('v1.InstanceAdminClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listInstanceConfigs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listInstanceConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstanceConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInstanceConfigs without error using callback', async () => { @@ -1443,15 +1960,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInstanceConfigsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.instance.v1.InstanceConfig() @@ -1484,11 +1997,14 @@ describe('v1.InstanceAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listInstanceConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstanceConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInstanceConfigs with error', async () => { @@ -1500,26 +2016,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInstanceConfigsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listInstanceConfigs = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listInstanceConfigs(request), expectedError); - assert( - (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listInstanceConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstanceConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInstanceConfigsStream without error', async () => { @@ -1531,8 +2046,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInstanceConfigsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.instance.v1.InstanceConfig() @@ -1572,11 +2090,12 @@ describe('v1.InstanceAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listInstanceConfigs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listInstanceConfigs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInstanceConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1589,8 +2108,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInstanceConfigsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listInstanceConfigs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1619,11 +2141,12 @@ describe('v1.InstanceAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listInstanceConfigs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listInstanceConfigs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInstanceConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1636,8 +2159,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInstanceConfigsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.instance.v1.InstanceConfig() @@ -1664,11 +2190,12 @@ describe('v1.InstanceAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1681,8 +2208,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInstanceConfigsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listInstanceConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1700,11 +2230,337 @@ describe('v1.InstanceAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( + (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listInstanceConfigOperations', () => { + it('invokes listInstanceConfigOperations without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'ListInstanceConfigOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.innerApiCalls.listInstanceConfigOperations = + stubSimpleCall(expectedResponse); + const [response] = await client.listInstanceConfigOperations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstanceConfigOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstanceConfigOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigOperations without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'ListInstanceConfigOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.innerApiCalls.listInstanceConfigOperations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstanceConfigOperations( + request, + ( + err?: Error | null, + result?: protos.google.longrunning.IOperation[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstanceConfigOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstanceConfigOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigOperations with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'ListInstanceConfigOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstanceConfigOperations = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.listInstanceConfigOperations(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.listInstanceConfigOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstanceConfigOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigOperationsStream without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'ListInstanceConfigOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.descriptors.page.listInstanceConfigOperations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstanceConfigOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.longrunning.Operation[] = []; + stream.on('data', (response: protos.google.longrunning.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( ( - client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + client.descriptors.page.listInstanceConfigOperations + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listInstanceConfigOperations, + request + ) + ); + assert( + ( + client.descriptors.page.listInstanceConfigOperations + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstanceConfigOperationsStream with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'ListInstanceConfigOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstanceConfigOperations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstanceConfigOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.longrunning.Operation[] = []; + stream.on('data', (response: protos.google.longrunning.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listInstanceConfigOperations + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listInstanceConfigOperations, + request + ) + ); + assert( + ( + client.descriptors.page.listInstanceConfigOperations + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstanceConfigOperations without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'ListInstanceConfigOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.descriptors.page.listInstanceConfigOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.longrunning.IOperation[] = []; + const iterable = client.listInstanceConfigOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstanceConfigOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.descriptors.page.listInstanceConfigOperations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstanceConfigOperations with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'ListInstanceConfigOperationsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstanceConfigOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstanceConfigOperationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstanceConfigOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.descriptors.page.listInstanceConfigOperations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1719,15 +2575,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstancesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInstancesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.instance.v1.Instance() @@ -1742,11 +2594,14 @@ describe('v1.InstanceAdminClient', () => { client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); const [response] = await client.listInstances(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listInstances as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInstances without error using callback', async () => { @@ -1758,15 +2613,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstancesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInstancesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.instance.v1.Instance() @@ -1797,11 +2648,14 @@ describe('v1.InstanceAdminClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listInstances as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInstances with error', async () => { @@ -1813,26 +2667,25 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstancesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInstancesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listInstances = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listInstances(request), expectedError); - assert( - (client.innerApiCalls.listInstances as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInstancesStream without error', async () => { @@ -1844,8 +2697,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstancesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInstancesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.instance.v1.Instance() @@ -1883,11 +2739,12 @@ describe('v1.InstanceAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listInstances, request) ); - assert.strictEqual( - ( - client.descriptors.page.listInstances.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1900,8 +2757,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstancesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInstancesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1928,11 +2788,12 @@ describe('v1.InstanceAdminClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listInstances, request) ); - assert.strictEqual( - ( - client.descriptors.page.listInstances.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1945,8 +2806,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstancesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInstancesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.spanner.admin.instance.v1.Instance() @@ -1972,11 +2836,12 @@ describe('v1.InstanceAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listInstances.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1989,8 +2854,11 @@ describe('v1.InstanceAdminClient', () => { const request = generateSampleMessage( new protos.google.spanner.admin.instance.v1.ListInstancesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInstancesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2008,11 +2876,12 @@ describe('v1.InstanceAdminClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listInstances.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_spanner_v1.ts b/test/gapic_spanner_v1.ts index e7f142eda..28002426d 100644 --- a/test/gapic_spanner_v1.ts +++ b/test/gapic_spanner_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -241,26 +256,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.CreateSessionRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSessionRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.Session() ); client.innerApiCalls.createSession = stubSimpleCall(expectedResponse); const [response] = await client.createSession(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSession without error using callback', async () => { @@ -272,15 +286,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.CreateSessionRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSessionRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.Session() ); @@ -303,11 +313,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSession with error', async () => { @@ -319,26 +332,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.CreateSessionRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSessionRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createSession = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createSession(request), expectedError); - assert( - (client.innerApiCalls.createSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSession with closed client', async () => { @@ -350,7 +362,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.CreateSessionRequest() ); - request.database = ''; + const defaultValue1 = getTypeDefaultValue('CreateSessionRequest', [ + 'database', + ]); + request.database = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createSession(request), expectedError); @@ -367,15 +382,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.BatchCreateSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.BatchCreateSessionsResponse() ); @@ -383,11 +394,14 @@ describe('v1.SpannerClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchCreateSessions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateSessions without error using callback', async () => { @@ -399,15 +413,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.BatchCreateSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.BatchCreateSessionsResponse() ); @@ -430,11 +440,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateSessions with error', async () => { @@ -446,26 +459,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.BatchCreateSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateSessions = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchCreateSessions(request), expectedError); - assert( - (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateSessions with closed client', async () => { @@ -477,7 +489,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.BatchCreateSessionsRequest() ); - request.database = ''; + const defaultValue1 = getTypeDefaultValue('BatchCreateSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.batchCreateSessions(request), expectedError); @@ -494,26 +509,23 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.GetSessionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.Session() ); client.innerApiCalls.getSession = stubSimpleCall(expectedResponse); const [response] = await client.getSession(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSession without error using callback', async () => { @@ -525,15 +537,9 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.GetSessionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.Session() ); @@ -556,11 +562,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSession with error', async () => { @@ -572,26 +581,23 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.GetSessionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getSession = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getSession(request), expectedError); - assert( - (client.innerApiCalls.getSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSession with closed client', async () => { @@ -603,7 +609,8 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.GetSessionRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetSessionRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getSession(request), expectedError); @@ -620,26 +627,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.DeleteSessionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSessionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteSession = stubSimpleCall(expectedResponse); const [response] = await client.deleteSession(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSession without error using callback', async () => { @@ -651,15 +657,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.DeleteSessionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSessionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -682,11 +684,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSession with error', async () => { @@ -698,26 +703,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.DeleteSessionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSessionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteSession = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteSession(request), expectedError); - assert( - (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSession with closed client', async () => { @@ -729,7 +733,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.DeleteSessionRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteSessionRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteSession(request), expectedError); @@ -746,26 +753,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteSqlRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExecuteSqlRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.ResultSet() ); client.innerApiCalls.executeSql = stubSimpleCall(expectedResponse); const [response] = await client.executeSql(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.executeSql as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes executeSql without error using callback', async () => { @@ -777,15 +783,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteSqlRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExecuteSqlRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.ResultSet() ); @@ -808,11 +810,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.executeSql as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes executeSql with error', async () => { @@ -824,26 +829,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteSqlRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExecuteSqlRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.executeSql = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.executeSql(request), expectedError); - assert( - (client.innerApiCalls.executeSql as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes executeSql with closed client', async () => { @@ -855,7 +859,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteSqlRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('ExecuteSqlRequest', [ + 'session', + ]); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.executeSql(request), expectedError); @@ -872,26 +879,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteBatchDmlRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExecuteBatchDmlRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.ExecuteBatchDmlResponse() ); client.innerApiCalls.executeBatchDml = stubSimpleCall(expectedResponse); const [response] = await client.executeBatchDml(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.executeBatchDml as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeBatchDml as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes executeBatchDml without error using callback', async () => { @@ -903,15 +909,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteBatchDmlRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExecuteBatchDmlRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.ExecuteBatchDmlResponse() ); @@ -934,11 +936,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.executeBatchDml as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeBatchDml as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes executeBatchDml with error', async () => { @@ -950,26 +955,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteBatchDmlRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExecuteBatchDmlRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.executeBatchDml = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.executeBatchDml(request), expectedError); - assert( - (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.executeBatchDml as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeBatchDml as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes executeBatchDml with closed client', async () => { @@ -981,7 +985,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteBatchDmlRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('ExecuteBatchDmlRequest', [ + 'session', + ]); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.executeBatchDml(request), expectedError); @@ -998,26 +1005,22 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ReadRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.ResultSet() ); client.innerApiCalls.read = stubSimpleCall(expectedResponse); const [response] = await client.read(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.read as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.read as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.read as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes read without error using callback', async () => { @@ -1029,15 +1032,9 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ReadRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.ResultSet() ); @@ -1059,11 +1056,13 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.read as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = (client.innerApiCalls.read as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.read as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes read with error', async () => { @@ -1075,23 +1074,19 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ReadRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.read = stubSimpleCall(undefined, expectedError); await assert.rejects(client.read(request), expectedError); - assert( - (client.innerApiCalls.read as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.read as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.read as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes read with closed client', async () => { @@ -1103,7 +1098,8 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ReadRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('ReadRequest', ['session']); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.read(request), expectedError); @@ -1120,26 +1116,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.BeginTransactionRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BeginTransactionRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.Transaction() ); client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); const [response] = await client.beginTransaction(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.beginTransaction as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.beginTransaction as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes beginTransaction without error using callback', async () => { @@ -1151,15 +1146,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.BeginTransactionRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BeginTransactionRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.Transaction() ); @@ -1182,11 +1173,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.beginTransaction as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.beginTransaction as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes beginTransaction with error', async () => { @@ -1198,26 +1192,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.BeginTransactionRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BeginTransactionRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.beginTransaction = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.beginTransaction(request), expectedError); - assert( - (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.beginTransaction as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.beginTransaction as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes beginTransaction with closed client', async () => { @@ -1229,7 +1222,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.BeginTransactionRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('BeginTransactionRequest', [ + 'session', + ]); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.beginTransaction(request), expectedError); @@ -1246,26 +1242,23 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.CommitRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CommitRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.CommitResponse() ); client.innerApiCalls.commit = stubSimpleCall(expectedResponse); const [response] = await client.commit(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.commit as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.commit as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes commit without error using callback', async () => { @@ -1277,15 +1270,9 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.CommitRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CommitRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.CommitResponse() ); @@ -1308,11 +1295,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.commit as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.commit as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes commit with error', async () => { @@ -1324,23 +1314,20 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.CommitRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CommitRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); await assert.rejects(client.commit(request), expectedError); - assert( - (client.innerApiCalls.commit as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.commit as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes commit with closed client', async () => { @@ -1352,7 +1339,8 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.CommitRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('CommitRequest', ['session']); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.commit(request), expectedError); @@ -1369,26 +1357,23 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.RollbackRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RollbackRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); const [response] = await client.rollback(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.rollback as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.rollback as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollback as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rollback without error using callback', async () => { @@ -1400,15 +1385,9 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.RollbackRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RollbackRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1431,11 +1410,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.rollback as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.rollback as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollback as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rollback with error', async () => { @@ -1447,23 +1429,20 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.RollbackRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RollbackRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); await assert.rejects(client.rollback(request), expectedError); - assert( - (client.innerApiCalls.rollback as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.rollback as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollback as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rollback with closed client', async () => { @@ -1475,7 +1454,8 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.RollbackRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('RollbackRequest', ['session']); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.rollback(request), expectedError); @@ -1492,26 +1472,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.PartitionQueryRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PartitionQueryRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.PartitionResponse() ); client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); const [response] = await client.partitionQuery(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.partitionQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.partitionQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes partitionQuery without error using callback', async () => { @@ -1523,15 +1502,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.PartitionQueryRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PartitionQueryRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.PartitionResponse() ); @@ -1554,11 +1529,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.partitionQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.partitionQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes partitionQuery with error', async () => { @@ -1570,26 +1548,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.PartitionQueryRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PartitionQueryRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.partitionQuery = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.partitionQuery(request), expectedError); - assert( - (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.partitionQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.partitionQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes partitionQuery with closed client', async () => { @@ -1601,7 +1578,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.PartitionQueryRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('PartitionQueryRequest', [ + 'session', + ]); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.partitionQuery(request), expectedError); @@ -1618,26 +1598,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.PartitionReadRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PartitionReadRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.PartitionResponse() ); client.innerApiCalls.partitionRead = stubSimpleCall(expectedResponse); const [response] = await client.partitionRead(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.partitionRead as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.partitionRead as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes partitionRead without error using callback', async () => { @@ -1649,15 +1628,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.PartitionReadRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PartitionReadRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.PartitionResponse() ); @@ -1680,11 +1655,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.partitionRead as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.partitionRead as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes partitionRead with error', async () => { @@ -1696,26 +1674,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.PartitionReadRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PartitionReadRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.partitionRead = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.partitionRead(request), expectedError); - assert( - (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.partitionRead as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.partitionRead as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes partitionRead with closed client', async () => { @@ -1727,7 +1704,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.PartitionReadRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('PartitionReadRequest', [ + 'session', + ]); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.partitionRead(request), expectedError); @@ -1744,15 +1724,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteSqlRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExecuteSqlRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.PartialResultSet() ); @@ -1772,11 +1748,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.executeStreamingSql as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.executeStreamingSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeStreamingSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes executeStreamingSql with error', async () => { @@ -1788,15 +1767,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteSqlRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExecuteSqlRequest', [ + 'session', + ]); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.executeStreamingSql = stubServerStreamingCall( undefined, @@ -1815,11 +1790,14 @@ describe('v1.SpannerClient', () => { }); }); await assert.rejects(promise, expectedError); - assert( - (client.innerApiCalls.executeStreamingSql as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.executeStreamingSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeStreamingSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes executeStreamingSql with closed client', async () => { @@ -1831,7 +1809,10 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ExecuteSqlRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('ExecuteSqlRequest', [ + 'session', + ]); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.executeStreamingSql(request); @@ -1860,15 +1841,9 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ReadRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.spanner.v1.PartialResultSet() ); @@ -1888,11 +1863,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.streamingRead as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.streamingRead as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.streamingRead as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes streamingRead with error', async () => { @@ -1904,15 +1882,9 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ReadRequest() ); - request.session = ''; - const expectedHeaderRequestParams = 'session='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.streamingRead = stubServerStreamingCall( undefined, @@ -1931,11 +1903,14 @@ describe('v1.SpannerClient', () => { }); }); await assert.rejects(promise, expectedError); - assert( - (client.innerApiCalls.streamingRead as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.streamingRead as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.streamingRead as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes streamingRead with closed client', async () => { @@ -1947,7 +1922,8 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ReadRequest() ); - request.session = ''; + const defaultValue1 = getTypeDefaultValue('ReadRequest', ['session']); + request.session = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.streamingRead(request); @@ -1976,15 +1952,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ListSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.spanner.v1.Session()), generateSampleMessage(new protos.google.spanner.v1.Session()), @@ -1993,11 +1965,14 @@ describe('v1.SpannerClient', () => { client.innerApiCalls.listSessions = stubSimpleCall(expectedResponse); const [response] = await client.listSessions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSessions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSessions without error using callback', async () => { @@ -2009,15 +1984,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ListSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.spanner.v1.Session()), generateSampleMessage(new protos.google.spanner.v1.Session()), @@ -2042,11 +2013,14 @@ describe('v1.SpannerClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSessions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSessions with error', async () => { @@ -2058,26 +2032,25 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ListSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listSessions = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listSessions(request), expectedError); - assert( - (client.innerApiCalls.listSessions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSessionsStream without error', async () => { @@ -2089,8 +2062,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ListSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; + const defaultValue1 = getTypeDefaultValue('ListSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.spanner.v1.Session()), generateSampleMessage(new protos.google.spanner.v1.Session()), @@ -2118,11 +2094,12 @@ describe('v1.SpannerClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSessions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSessions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSessions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2135,8 +2112,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ListSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; + const defaultValue1 = getTypeDefaultValue('ListSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSessions.createStream = stubPageStreamingCall( undefined, @@ -2161,11 +2141,12 @@ describe('v1.SpannerClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSessions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSessions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSessions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2178,8 +2159,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ListSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; + const defaultValue1 = getTypeDefaultValue('ListSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.spanner.v1.Session()), generateSampleMessage(new protos.google.spanner.v1.Session()), @@ -2199,11 +2183,12 @@ describe('v1.SpannerClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSessions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2216,8 +2201,11 @@ describe('v1.SpannerClient', () => { const request = generateSampleMessage( new protos.google.spanner.v1.ListSessionsRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; + const defaultValue1 = getTypeDefaultValue('ListSessionsRequest', [ + 'database', + ]); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2234,11 +2222,12 @@ describe('v1.SpannerClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSessions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); });