diff --git a/packages/google-cloud-run/README.md b/packages/google-cloud-run/README.md index 384f8db772e..5e764dd1d71 100644 --- a/packages/google-cloud-run/README.md +++ b/packages/google-cloud-run/README.md @@ -63,6 +63,12 @@ Samples are in the [`samples/`][homepage_samples] directory. Each sample's `READ | delete execution | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/executions.delete_execution.js) | | get execution | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/executions.get_execution.js) | | list executions | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/executions.list_executions.js) | +| create instance | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/instances.create_instance.js) | +| delete instance | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/instances.delete_instance.js) | +| get instance | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/instances.get_instance.js) | +| list instances | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/instances.list_instances.js) | +| start instance | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/instances.start_instance.js) | +| stop instance | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/instances.stop_instance.js) | | create job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/jobs.create_job.js) | | delete job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/jobs.delete_job.js) | | get iam policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-run/samples/generated/v2/jobs.get_iam_policy.js) | diff --git a/packages/google-cloud-run/protos/google/cloud/run/v2/container_status.proto b/packages/google-cloud-run/protos/google/cloud/run/v2/container_status.proto new file mode 100644 index 00000000000..6043fa698dc --- /dev/null +++ b/packages/google-cloud-run/protos/google/cloud/run/v2/container_status.proto @@ -0,0 +1,35 @@ +// Copyright 2026 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.cloud.run.v2; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "ContainerStatusProto"; +option java_package = "com.google.cloud.run.v2"; + +// ContainerStatus holds the information of container name and image digest +// value. +message ContainerStatus { + // The name of the container, if specified. + string name = 1; + + // ImageDigest holds the resolved digest for the image specified and resolved + // during the creation of Revision. This field holds the digest value + // regardless of whether a tag or digest was originally specified in the + // Container object. + string image_digest = 2; +} diff --git a/packages/google-cloud-run/protos/google/cloud/run/v2/instance.proto b/packages/google-cloud-run/protos/google/cloud/run/v2/instance.proto new file mode 100644 index 00000000000..f8b88cd57e4 --- /dev/null +++ b/packages/google-cloud-run/protos/google/cloud/run/v2/instance.proto @@ -0,0 +1,434 @@ +// Copyright 2026 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.cloud.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/api/routing.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/container_status.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.run.v2"; + +// The Cloud Run Instances API allows you to manage Cloud Run Instances. +service Instances { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates an Instance. + rpc CreateInstance(CreateInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/instances" + body: "instance" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}" + } + }; + option (google.api.method_signature) = "parent,instance"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "Instance" + }; + } + + // Deletes a Instance + rpc DeleteInstance(DeleteInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "Instance" + }; + } + + // Gets a Instance + rpc GetInstance(GetInstanceRequest) returns (Instance) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + } + + // Lists Instances. Results are sorted by creation time, descending. + rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/instances" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Stops an Instance. + rpc StopInstance(StopInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/instances/*}:stop" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "Instance" + }; + } + + // Starts an Instance. + rpc StartInstance(StartInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/instances/*}:start" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "Instance" + }; + } +} + +message CreateInstanceRequest { + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Instance" + } + ]; + + Instance instance = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The unique identifier for the Instance. It must begin with + // letter, and cannot end with hyphen; must contain fewer than 50 characters. + // The name of the instance becomes {parent}/instances/{instance_id}. + string instance_id = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Indicates that the request should be validated and default values + // populated, without persisting the request or creating any resources. + bool validate_only = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +message GetInstanceRequest { + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Instance" } + ]; +} + +message DeleteInstanceRequest { + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Instance" } + ]; + + // Optional. Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for retrieving a list of Instances. +message ListInstancesRequest { + // Required. The location and project to list resources on. + // Format: projects/{project}/locations/{location}, where {project} can be + // project id or number. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Instance" + } + ]; + + // Optional. Maximum number of Instances to return in this call. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token received from a previous call to ListInstances. + // All other parameters must match. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If true, returns deleted (but unexpired) resources along with + // active ones. + bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response message containing a list of Instances. +message ListInstancesResponse { + // The resulting list of Instances. + repeated Instance instances = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListInstances request to continue. + string next_page_token = 2; +} + +// Request message for deleting an Instance. +message StopInstanceRequest { + // Required. The name of the Instance to stop. + // Format: + // `projects/{project}/locations/{location}/instances/{instance}`, + // where `{project}` can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Instance" } + ]; + + // Optional. Indicates that the request should be validated without actually + // stopping any resources. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A system-generated fingerprint for this version of the resource. + // This may be used to detect modification conflict during updates. + string etag = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for starting an Instance. +message StartInstanceRequest { + // Required. The name of the Instance to stop. + // Format: + // `projects/{project}/locations/{location}/instances/{instance}`, + // where `{project}` can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Instance" } + ]; + + // Optional. Indicates that the request should be validated without actually + // stopping any resources. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A system-generated fingerprint for this version of the resource. + // This may be used to detect modification conflict during updates. + string etag = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A Cloud Run Instance represents a single group of containers running in a +// region. +message Instance { + option (google.api.resource) = { + type: "run.googleapis.com/Instance" + pattern: "projects/{project}/locations/{location}/instances/{instance}" + plural: "instances" + singular: "instance" + }; + + // The fully qualified name of this Instance. In CreateInstanceRequest, this + // field is ignored, and instead composed from CreateInstanceRequest.parent + // and CreateInstanceRequest.instance_id. + // + // Format: + // projects/{project}/locations/{location}/instances/{instance_id} + string name = 1; + + // User-provided description of the Instance. This field currently has a + // 512-character limit. + string description = 3; + + // Output only. Server assigned unique identifier for the trigger. The value + // is a UUID4 string and guaranteed to remain unchanged until the resource is + // deleted. + string uid = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + // Please note that unlike v1, this is an int64 value. As with most Google + // APIs, its JSON representation will be a `string` instead of an `integer`. + int64 generation = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + map labels = 6; + + map annotations = 7; + + // Output only. The creation time. + google.protobuf.Timestamp create_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The deletion time. + google.protobuf.Timestamp delete_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. + google.protobuf.Timestamp expire_time = 11 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the authenticated creator. + string creator = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the last authenticated modifier. + string last_modifier = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Arbitrary identifier for the API client. + string client = 14; + + // Arbitrary version identifier for the API client. + string client_version = 15; + + // The launch stage as defined by [Google Cloud Platform + // Launch Stages](https://cloud.google.com/terms/launch-stages). + // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA + // is assumed. + // Set the launch stage to a preview stage on input to allow use of preview + // features in that stage. On read (or output), describes whether the + // resource uses preview features. + //

+ // For example, if ALPHA is provided as input, but only BETA and GA-level + // features are used, this field will be BETA on output. + google.api.LaunchStage launch_stage = 16; + + // Settings for the Binary Authorization feature. + BinaryAuthorization binary_authorization = 17; + + // Optional. VPC Access configuration to use for this Revision. For more + // information, visit + // https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 18 [(google.api.field_behavior) = OPTIONAL]; + + string service_account = 19; + + // Required. Holds the single container that defines the unit of execution for + // this Instance. + repeated Container containers = 20 [(google.api.field_behavior) = REQUIRED]; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 21; + + // A reference to a customer managed encryption key (CMEK) to use to encrypt + // this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 22 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // The action to take if the encryption key is revoked. + EncryptionKeyRevocationAction encryption_key_revocation_action = 24; + + // If encryption_key_revocation_action is SHUTDOWN, the duration before + // shutting down all instances. The minimum increment is 1 hour. + google.protobuf.Duration encryption_key_shutdown_duration = 25; + + // Optional. The node selector for the instance. + NodeSelector node_selector = 26 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. True if GPU zonal redundancy is disabled on this instance. + optional bool gpu_zonal_redundancy_disabled = 27 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Provides the ingress settings for this Instance. On output, + // returns the currently observed ingress settings, or + // INGRESS_TRAFFIC_UNSPECIFIED if no revision is active. + IngressTraffic ingress = 28 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Disables IAM permission check for run.routes.invoke for callers + // of this Instance. For more information, visit + // https://cloud.google.com/run/docs/securing/managing-access#invoker_check. + bool invoker_iam_disabled = 29 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. IAP settings on the Instance. + bool iap_enabled = 30 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The generation of this Instance currently serving traffic. See + // comments in `reconciling` for additional information on reconciliation + // process in Cloud Run. Please note that unlike v1, this is an int64 value. + // As with most Google APIs, its JSON representation will be a `string` + // instead of an `integer`. + int64 observed_generation = 40 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Google Console URI to obtain logs for the Instance. + string log_uri = 41 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Instance, containing its readiness + // status, and detailed error information in case it did not reach a serving + // state. See comments in `reconciling` for additional information on + // reconciliation process in Cloud Run. + Condition terminal_condition = 42 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Conditions of all other associated sub-resources. They + // contain additional diagnostics information in case the Instance does not + // reach its Serving state. See comments in `reconciling` for additional + // information on reconciliation process in Cloud Run. + repeated Condition conditions = 43 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Status information for each of the specified containers. The + // status includes the resolved digest for specified images. + repeated ContainerStatus container_statuses = 44 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reserved for future use. + bool satisfies_pzs = 46 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. All URLs serving traffic for this Instance. + repeated string urls = 45 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Returns true if the Instance is currently being acted upon by + // the system to bring it into the desired state. + // + // When a new Instance is created, or an existing one is updated, Cloud Run + // will asynchronously perform all necessary steps to bring the Instance to + // the desired serving state. This process is called reconciliation. While + // reconciliation is in process, `observed_generation` will have a transient + // value that might mismatch the intended state. + // Once reconciliation is over (and this field is false), there are two + // possible outcomes: reconciliation succeeded and the serving state matches + // the Instance, or there was an error, and reconciliation failed. This state + // can be found in `terminal_condition.state`. + bool reconciling = 98 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/packages/google-cloud-run/protos/google/cloud/run/v2/k8s.min.proto b/packages/google-cloud-run/protos/google/cloud/run/v2/k8s.min.proto index 83b9af76787..0fe03f27aac 100644 --- a/packages/google-cloud-run/protos/google/cloud/run/v2/k8s.min.proto +++ b/packages/google-cloud-run/protos/google/cloud/run/v2/k8s.min.proto @@ -97,6 +97,9 @@ message Container { // fails. Probe startup_probe = 11; + // Readiness probe to be used for health checks. + Probe readiness_probe = 14; + // Names of the containers that must start before this container. repeated string depends_on = 12; diff --git a/packages/google-cloud-run/protos/protos.d.ts b/packages/google-cloud-run/protos/protos.d.ts index 3689d39331d..0f969068560 100644 --- a/packages/google-cloud-run/protos/protos.d.ts +++ b/packages/google-cloud-run/protos/protos.d.ts @@ -889,6 +889,109 @@ export namespace google { } } + /** Properties of a ContainerStatus. */ + interface IContainerStatus { + + /** ContainerStatus name */ + name?: (string|null); + + /** ContainerStatus imageDigest */ + imageDigest?: (string|null); + } + + /** Represents a ContainerStatus. */ + class ContainerStatus implements IContainerStatus { + + /** + * Constructs a new ContainerStatus. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.IContainerStatus); + + /** ContainerStatus name. */ + public name: string; + + /** ContainerStatus imageDigest. */ + public imageDigest: string; + + /** + * Creates a new ContainerStatus instance using the specified properties. + * @param [properties] Properties to set + * @returns ContainerStatus instance + */ + public static create(properties?: google.cloud.run.v2.IContainerStatus): google.cloud.run.v2.ContainerStatus; + + /** + * Encodes the specified ContainerStatus message. Does not implicitly {@link google.cloud.run.v2.ContainerStatus.verify|verify} messages. + * @param message ContainerStatus message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.run.v2.IContainerStatus, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ContainerStatus message, length delimited. Does not implicitly {@link google.cloud.run.v2.ContainerStatus.verify|verify} messages. + * @param message ContainerStatus message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.run.v2.IContainerStatus, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ContainerStatus message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ContainerStatus + * @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.cloud.run.v2.ContainerStatus; + + /** + * Decodes a ContainerStatus message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ContainerStatus + * @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.cloud.run.v2.ContainerStatus; + + /** + * Verifies a ContainerStatus 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 ContainerStatus message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ContainerStatus + */ + public static fromObject(object: { [k: string]: any }): google.cloud.run.v2.ContainerStatus; + + /** + * Creates a plain object from a ContainerStatus message. Also converts values to other types if specified. + * @param message ContainerStatus + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.run.v2.ContainerStatus, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ContainerStatus to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ContainerStatus + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Represents an Executions */ class Executions extends $protobuf.rpc.Service { @@ -1982,6 +2085,9 @@ export namespace google { /** Container startupProbe */ startupProbe?: (google.cloud.run.v2.IProbe|null); + /** Container readinessProbe */ + readinessProbe?: (google.cloud.run.v2.IProbe|null); + /** Container dependsOn */ dependsOn?: (string[]|null); @@ -2037,6 +2143,9 @@ export namespace google { /** Container startupProbe. */ public startupProbe?: (google.cloud.run.v2.IProbe|null); + /** Container readinessProbe. */ + public readinessProbe?: (google.cloud.run.v2.IProbe|null); + /** Container dependsOn. */ public dependsOn: string[]; @@ -5543,6 +5652,1226 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Represents an Instances */ + class Instances extends $protobuf.rpc.Service { + + /** + * Constructs a new Instances service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new Instances service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Instances; + + /** + * Calls CreateInstance. + * @param request CreateInstanceRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createInstance(request: google.cloud.run.v2.ICreateInstanceRequest, callback: google.cloud.run.v2.Instances.CreateInstanceCallback): void; + + /** + * Calls CreateInstance. + * @param request CreateInstanceRequest message or plain object + * @returns Promise + */ + public createInstance(request: google.cloud.run.v2.ICreateInstanceRequest): Promise; + + /** + * Calls DeleteInstance. + * @param request DeleteInstanceRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public deleteInstance(request: google.cloud.run.v2.IDeleteInstanceRequest, callback: google.cloud.run.v2.Instances.DeleteInstanceCallback): void; + + /** + * Calls DeleteInstance. + * @param request DeleteInstanceRequest message or plain object + * @returns Promise + */ + public deleteInstance(request: google.cloud.run.v2.IDeleteInstanceRequest): Promise; + + /** + * Calls GetInstance. + * @param request GetInstanceRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Instance + */ + public getInstance(request: google.cloud.run.v2.IGetInstanceRequest, callback: google.cloud.run.v2.Instances.GetInstanceCallback): void; + + /** + * Calls GetInstance. + * @param request GetInstanceRequest message or plain object + * @returns Promise + */ + public getInstance(request: google.cloud.run.v2.IGetInstanceRequest): Promise; + + /** + * Calls ListInstances. + * @param request ListInstancesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListInstancesResponse + */ + public listInstances(request: google.cloud.run.v2.IListInstancesRequest, callback: google.cloud.run.v2.Instances.ListInstancesCallback): void; + + /** + * Calls ListInstances. + * @param request ListInstancesRequest message or plain object + * @returns Promise + */ + public listInstances(request: google.cloud.run.v2.IListInstancesRequest): Promise; + + /** + * Calls StopInstance. + * @param request StopInstanceRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public stopInstance(request: google.cloud.run.v2.IStopInstanceRequest, callback: google.cloud.run.v2.Instances.StopInstanceCallback): void; + + /** + * Calls StopInstance. + * @param request StopInstanceRequest message or plain object + * @returns Promise + */ + public stopInstance(request: google.cloud.run.v2.IStopInstanceRequest): Promise; + + /** + * Calls StartInstance. + * @param request StartInstanceRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public startInstance(request: google.cloud.run.v2.IStartInstanceRequest, callback: google.cloud.run.v2.Instances.StartInstanceCallback): void; + + /** + * Calls StartInstance. + * @param request StartInstanceRequest message or plain object + * @returns Promise + */ + public startInstance(request: google.cloud.run.v2.IStartInstanceRequest): Promise; + } + + namespace Instances { + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|createInstance}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateInstanceCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|deleteInstance}. + * @param error Error, if any + * @param [response] Operation + */ + type DeleteInstanceCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|getInstance}. + * @param error Error, if any + * @param [response] Instance + */ + type GetInstanceCallback = (error: (Error|null), response?: google.cloud.run.v2.Instance) => void; + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|listInstances}. + * @param error Error, if any + * @param [response] ListInstancesResponse + */ + type ListInstancesCallback = (error: (Error|null), response?: google.cloud.run.v2.ListInstancesResponse) => void; + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|stopInstance}. + * @param error Error, if any + * @param [response] Operation + */ + type StopInstanceCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|startInstance}. + * @param error Error, if any + * @param [response] Operation + */ + type StartInstanceCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateInstanceRequest. */ + interface ICreateInstanceRequest { + + /** CreateInstanceRequest parent */ + parent?: (string|null); + + /** CreateInstanceRequest instance */ + instance?: (google.cloud.run.v2.IInstance|null); + + /** CreateInstanceRequest instanceId */ + instanceId?: (string|null); + + /** CreateInstanceRequest validateOnly */ + validateOnly?: (boolean|null); + } + + /** Represents a CreateInstanceRequest. */ + class CreateInstanceRequest implements ICreateInstanceRequest { + + /** + * Constructs a new CreateInstanceRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.ICreateInstanceRequest); + + /** CreateInstanceRequest parent. */ + public parent: string; + + /** CreateInstanceRequest instance. */ + public instance?: (google.cloud.run.v2.IInstance|null); + + /** CreateInstanceRequest instanceId. */ + public instanceId: string; + + /** CreateInstanceRequest validateOnly. */ + public validateOnly: boolean; + + /** + * Creates a new CreateInstanceRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateInstanceRequest instance + */ + public static create(properties?: google.cloud.run.v2.ICreateInstanceRequest): google.cloud.run.v2.CreateInstanceRequest; + + /** + * Encodes the specified CreateInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.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.cloud.run.v2.ICreateInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.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.cloud.run.v2.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.cloud.run.v2.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 + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.run.v2.CreateInstanceRequest; + + /** + * Verifies a CreateInstanceRequest 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 CreateInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateInstanceRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.run.v2.CreateInstanceRequest; + + /** + * Creates a plain object from a CreateInstanceRequest message. Also converts values to other types if specified. + * @param message CreateInstanceRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.run.v2.CreateInstanceRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateInstanceRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateInstanceRequest + * @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); + } + + /** Represents a GetInstanceRequest. */ + class GetInstanceRequest implements IGetInstanceRequest { + + /** + * Constructs a new GetInstanceRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.IGetInstanceRequest); + + /** GetInstanceRequest name. */ + public name: string; + + /** + * Creates a new GetInstanceRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetInstanceRequest instance + */ + public static create(properties?: google.cloud.run.v2.IGetInstanceRequest): google.cloud.run.v2.GetInstanceRequest; + + /** + * Encodes the specified GetInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.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.cloud.run.v2.IGetInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.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.cloud.run.v2.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.cloud.run.v2.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.cloud.run.v2.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.cloud.run.v2.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.cloud.run.v2.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 DeleteInstanceRequest. */ + interface IDeleteInstanceRequest { + + /** DeleteInstanceRequest name */ + name?: (string|null); + + /** DeleteInstanceRequest validateOnly */ + validateOnly?: (boolean|null); + + /** DeleteInstanceRequest etag */ + etag?: (string|null); + } + + /** Represents a DeleteInstanceRequest. */ + class DeleteInstanceRequest implements IDeleteInstanceRequest { + + /** + * Constructs a new DeleteInstanceRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.IDeleteInstanceRequest); + + /** DeleteInstanceRequest name. */ + public name: string; + + /** DeleteInstanceRequest validateOnly. */ + public validateOnly: boolean; + + /** DeleteInstanceRequest etag. */ + public etag: string; + + /** + * Creates a new DeleteInstanceRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteInstanceRequest instance + */ + public static create(properties?: google.cloud.run.v2.IDeleteInstanceRequest): google.cloud.run.v2.DeleteInstanceRequest; + + /** + * Encodes the specified DeleteInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.DeleteInstanceRequest.verify|verify} messages. + * @param message DeleteInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.run.v2.IDeleteInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.DeleteInstanceRequest.verify|verify} messages. + * @param message DeleteInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.run.v2.IDeleteInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteInstanceRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteInstanceRequest + * @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.cloud.run.v2.DeleteInstanceRequest; + + /** + * Decodes a DeleteInstanceRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteInstanceRequest + * @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.cloud.run.v2.DeleteInstanceRequest; + + /** + * Verifies a DeleteInstanceRequest 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 DeleteInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteInstanceRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.run.v2.DeleteInstanceRequest; + + /** + * Creates a plain object from a DeleteInstanceRequest message. Also converts values to other types if specified. + * @param message DeleteInstanceRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.run.v2.DeleteInstanceRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteInstanceRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteInstanceRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListInstancesRequest. */ + interface IListInstancesRequest { + + /** ListInstancesRequest parent */ + parent?: (string|null); + + /** ListInstancesRequest pageSize */ + pageSize?: (number|null); + + /** ListInstancesRequest pageToken */ + pageToken?: (string|null); + + /** ListInstancesRequest showDeleted */ + showDeleted?: (boolean|null); + } + + /** Represents a ListInstancesRequest. */ + class ListInstancesRequest implements IListInstancesRequest { + + /** + * Constructs a new ListInstancesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.IListInstancesRequest); + + /** ListInstancesRequest parent. */ + public parent: string; + + /** ListInstancesRequest pageSize. */ + public pageSize: number; + + /** ListInstancesRequest pageToken. */ + public pageToken: string; + + /** ListInstancesRequest showDeleted. */ + public showDeleted: boolean; + + /** + * Creates a new ListInstancesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListInstancesRequest instance + */ + public static create(properties?: google.cloud.run.v2.IListInstancesRequest): google.cloud.run.v2.ListInstancesRequest; + + /** + * Encodes the specified ListInstancesRequest message. Does not implicitly {@link google.cloud.run.v2.ListInstancesRequest.verify|verify} messages. + * @param message ListInstancesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.run.v2.IListInstancesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListInstancesRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.ListInstancesRequest.verify|verify} messages. + * @param message ListInstancesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.run.v2.IListInstancesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListInstancesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListInstancesRequest + * @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.cloud.run.v2.ListInstancesRequest; + + /** + * Decodes a ListInstancesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListInstancesRequest + * @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.cloud.run.v2.ListInstancesRequest; + + /** + * Verifies a ListInstancesRequest 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 ListInstancesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListInstancesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.run.v2.ListInstancesRequest; + + /** + * Creates a plain object from a ListInstancesRequest message. Also converts values to other types if specified. + * @param message ListInstancesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.run.v2.ListInstancesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListInstancesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListInstancesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListInstancesResponse. */ + interface IListInstancesResponse { + + /** ListInstancesResponse instances */ + instances?: (google.cloud.run.v2.IInstance[]|null); + + /** ListInstancesResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListInstancesResponse. */ + class ListInstancesResponse implements IListInstancesResponse { + + /** + * Constructs a new ListInstancesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.IListInstancesResponse); + + /** ListInstancesResponse instances. */ + public instances: google.cloud.run.v2.IInstance[]; + + /** ListInstancesResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListInstancesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListInstancesResponse instance + */ + public static create(properties?: google.cloud.run.v2.IListInstancesResponse): google.cloud.run.v2.ListInstancesResponse; + + /** + * Encodes the specified ListInstancesResponse message. Does not implicitly {@link google.cloud.run.v2.ListInstancesResponse.verify|verify} messages. + * @param message ListInstancesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.run.v2.IListInstancesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListInstancesResponse message, length delimited. Does not implicitly {@link google.cloud.run.v2.ListInstancesResponse.verify|verify} messages. + * @param message ListInstancesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.run.v2.IListInstancesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListInstancesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListInstancesResponse + * @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.cloud.run.v2.ListInstancesResponse; + + /** + * Decodes a ListInstancesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListInstancesResponse + * @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.cloud.run.v2.ListInstancesResponse; + + /** + * Verifies a ListInstancesResponse 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 ListInstancesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListInstancesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.run.v2.ListInstancesResponse; + + /** + * Creates a plain object from a ListInstancesResponse message. Also converts values to other types if specified. + * @param message ListInstancesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.run.v2.ListInstancesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListInstancesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListInstancesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StopInstanceRequest. */ + interface IStopInstanceRequest { + + /** StopInstanceRequest name */ + name?: (string|null); + + /** StopInstanceRequest validateOnly */ + validateOnly?: (boolean|null); + + /** StopInstanceRequest etag */ + etag?: (string|null); + } + + /** Represents a StopInstanceRequest. */ + class StopInstanceRequest implements IStopInstanceRequest { + + /** + * Constructs a new StopInstanceRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.IStopInstanceRequest); + + /** StopInstanceRequest name. */ + public name: string; + + /** StopInstanceRequest validateOnly. */ + public validateOnly: boolean; + + /** StopInstanceRequest etag. */ + public etag: string; + + /** + * Creates a new StopInstanceRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StopInstanceRequest instance + */ + public static create(properties?: google.cloud.run.v2.IStopInstanceRequest): google.cloud.run.v2.StopInstanceRequest; + + /** + * Encodes the specified StopInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.StopInstanceRequest.verify|verify} messages. + * @param message StopInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.run.v2.IStopInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StopInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.StopInstanceRequest.verify|verify} messages. + * @param message StopInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.run.v2.IStopInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StopInstanceRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StopInstanceRequest + * @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.cloud.run.v2.StopInstanceRequest; + + /** + * Decodes a StopInstanceRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StopInstanceRequest + * @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.cloud.run.v2.StopInstanceRequest; + + /** + * Verifies a StopInstanceRequest 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 StopInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StopInstanceRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.run.v2.StopInstanceRequest; + + /** + * Creates a plain object from a StopInstanceRequest message. Also converts values to other types if specified. + * @param message StopInstanceRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.run.v2.StopInstanceRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StopInstanceRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StopInstanceRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StartInstanceRequest. */ + interface IStartInstanceRequest { + + /** StartInstanceRequest name */ + name?: (string|null); + + /** StartInstanceRequest validateOnly */ + validateOnly?: (boolean|null); + + /** StartInstanceRequest etag */ + etag?: (string|null); + } + + /** Represents a StartInstanceRequest. */ + class StartInstanceRequest implements IStartInstanceRequest { + + /** + * Constructs a new StartInstanceRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.IStartInstanceRequest); + + /** StartInstanceRequest name. */ + public name: string; + + /** StartInstanceRequest validateOnly. */ + public validateOnly: boolean; + + /** StartInstanceRequest etag. */ + public etag: string; + + /** + * Creates a new StartInstanceRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StartInstanceRequest instance + */ + public static create(properties?: google.cloud.run.v2.IStartInstanceRequest): google.cloud.run.v2.StartInstanceRequest; + + /** + * Encodes the specified StartInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.StartInstanceRequest.verify|verify} messages. + * @param message StartInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.run.v2.IStartInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StartInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.StartInstanceRequest.verify|verify} messages. + * @param message StartInstanceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.run.v2.IStartInstanceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StartInstanceRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StartInstanceRequest + * @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.cloud.run.v2.StartInstanceRequest; + + /** + * Decodes a StartInstanceRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StartInstanceRequest + * @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.cloud.run.v2.StartInstanceRequest; + + /** + * Verifies a StartInstanceRequest 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 StartInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StartInstanceRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.run.v2.StartInstanceRequest; + + /** + * Creates a plain object from a StartInstanceRequest message. Also converts values to other types if specified. + * @param message StartInstanceRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.run.v2.StartInstanceRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StartInstanceRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StartInstanceRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Instance. */ + interface IInstance { + + /** Instance name */ + name?: (string|null); + + /** Instance description */ + description?: (string|null); + + /** Instance uid */ + uid?: (string|null); + + /** Instance generation */ + generation?: (number|Long|string|null); + + /** Instance labels */ + labels?: ({ [k: string]: string }|null); + + /** Instance annotations */ + annotations?: ({ [k: string]: string }|null); + + /** Instance createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** Instance updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** Instance deleteTime */ + deleteTime?: (google.protobuf.ITimestamp|null); + + /** Instance expireTime */ + expireTime?: (google.protobuf.ITimestamp|null); + + /** Instance creator */ + creator?: (string|null); + + /** Instance lastModifier */ + lastModifier?: (string|null); + + /** Instance client */ + client?: (string|null); + + /** Instance clientVersion */ + clientVersion?: (string|null); + + /** Instance launchStage */ + launchStage?: (google.api.LaunchStage|keyof typeof google.api.LaunchStage|null); + + /** Instance binaryAuthorization */ + binaryAuthorization?: (google.cloud.run.v2.IBinaryAuthorization|null); + + /** Instance vpcAccess */ + vpcAccess?: (google.cloud.run.v2.IVpcAccess|null); + + /** Instance serviceAccount */ + serviceAccount?: (string|null); + + /** Instance containers */ + containers?: (google.cloud.run.v2.IContainer[]|null); + + /** Instance volumes */ + volumes?: (google.cloud.run.v2.IVolume[]|null); + + /** Instance encryptionKey */ + encryptionKey?: (string|null); + + /** Instance encryptionKeyRevocationAction */ + encryptionKeyRevocationAction?: (google.cloud.run.v2.EncryptionKeyRevocationAction|keyof typeof google.cloud.run.v2.EncryptionKeyRevocationAction|null); + + /** Instance encryptionKeyShutdownDuration */ + encryptionKeyShutdownDuration?: (google.protobuf.IDuration|null); + + /** Instance nodeSelector */ + nodeSelector?: (google.cloud.run.v2.INodeSelector|null); + + /** Instance gpuZonalRedundancyDisabled */ + gpuZonalRedundancyDisabled?: (boolean|null); + + /** Instance ingress */ + ingress?: (google.cloud.run.v2.IngressTraffic|keyof typeof google.cloud.run.v2.IngressTraffic|null); + + /** Instance invokerIamDisabled */ + invokerIamDisabled?: (boolean|null); + + /** Instance iapEnabled */ + iapEnabled?: (boolean|null); + + /** Instance observedGeneration */ + observedGeneration?: (number|Long|string|null); + + /** Instance logUri */ + logUri?: (string|null); + + /** Instance terminalCondition */ + terminalCondition?: (google.cloud.run.v2.ICondition|null); + + /** Instance conditions */ + conditions?: (google.cloud.run.v2.ICondition[]|null); + + /** Instance containerStatuses */ + containerStatuses?: (google.cloud.run.v2.IContainerStatus[]|null); + + /** Instance satisfiesPzs */ + satisfiesPzs?: (boolean|null); + + /** Instance urls */ + urls?: (string[]|null); + + /** Instance reconciling */ + reconciling?: (boolean|null); + + /** Instance etag */ + etag?: (string|null); + } + + /** Represents an Instance. */ + class Instance implements IInstance { + + /** + * Constructs a new Instance. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.run.v2.IInstance); + + /** Instance name. */ + public name: string; + + /** Instance description. */ + public description: string; + + /** Instance uid. */ + public uid: string; + + /** Instance generation. */ + public generation: (number|Long|string); + + /** Instance labels. */ + public labels: { [k: string]: string }; + + /** Instance annotations. */ + public annotations: { [k: string]: string }; + + /** Instance createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** Instance updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** Instance deleteTime. */ + public deleteTime?: (google.protobuf.ITimestamp|null); + + /** Instance expireTime. */ + public expireTime?: (google.protobuf.ITimestamp|null); + + /** Instance creator. */ + public creator: string; + + /** Instance lastModifier. */ + public lastModifier: string; + + /** Instance client. */ + public client: string; + + /** Instance clientVersion. */ + public clientVersion: string; + + /** Instance launchStage. */ + public launchStage: (google.api.LaunchStage|keyof typeof google.api.LaunchStage); + + /** Instance binaryAuthorization. */ + public binaryAuthorization?: (google.cloud.run.v2.IBinaryAuthorization|null); + + /** Instance vpcAccess. */ + public vpcAccess?: (google.cloud.run.v2.IVpcAccess|null); + + /** Instance serviceAccount. */ + public serviceAccount: string; + + /** Instance containers. */ + public containers: google.cloud.run.v2.IContainer[]; + + /** Instance volumes. */ + public volumes: google.cloud.run.v2.IVolume[]; + + /** Instance encryptionKey. */ + public encryptionKey: string; + + /** Instance encryptionKeyRevocationAction. */ + public encryptionKeyRevocationAction: (google.cloud.run.v2.EncryptionKeyRevocationAction|keyof typeof google.cloud.run.v2.EncryptionKeyRevocationAction); + + /** Instance encryptionKeyShutdownDuration. */ + public encryptionKeyShutdownDuration?: (google.protobuf.IDuration|null); + + /** Instance nodeSelector. */ + public nodeSelector?: (google.cloud.run.v2.INodeSelector|null); + + /** Instance gpuZonalRedundancyDisabled. */ + public gpuZonalRedundancyDisabled?: (boolean|null); + + /** Instance ingress. */ + public ingress: (google.cloud.run.v2.IngressTraffic|keyof typeof google.cloud.run.v2.IngressTraffic); + + /** Instance invokerIamDisabled. */ + public invokerIamDisabled: boolean; + + /** Instance iapEnabled. */ + public iapEnabled: boolean; + + /** Instance observedGeneration. */ + public observedGeneration: (number|Long|string); + + /** Instance logUri. */ + public logUri: string; + + /** Instance terminalCondition. */ + public terminalCondition?: (google.cloud.run.v2.ICondition|null); + + /** Instance conditions. */ + public conditions: google.cloud.run.v2.ICondition[]; + + /** Instance containerStatuses. */ + public containerStatuses: google.cloud.run.v2.IContainerStatus[]; + + /** Instance satisfiesPzs. */ + public satisfiesPzs: boolean; + + /** Instance urls. */ + public urls: string[]; + + /** Instance reconciling. */ + public reconciling: boolean; + + /** Instance etag. */ + public etag: string; + + /** + * Creates a new Instance instance using the specified properties. + * @param [properties] Properties to set + * @returns Instance instance + */ + public static create(properties?: google.cloud.run.v2.IInstance): google.cloud.run.v2.Instance; + + /** + * Encodes the specified Instance message. Does not implicitly {@link google.cloud.run.v2.Instance.verify|verify} messages. + * @param message Instance message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.run.v2.IInstance, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Instance message, length delimited. Does not implicitly {@link google.cloud.run.v2.Instance.verify|verify} messages. + * @param message Instance message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.run.v2.IInstance, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Instance message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Instance + * @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.cloud.run.v2.Instance; + + /** + * Decodes an Instance message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Instance + * @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.cloud.run.v2.Instance; + + /** + * Verifies an Instance 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 Instance message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Instance + */ + public static fromObject(object: { [k: string]: any }): google.cloud.run.v2.Instance; + + /** + * Creates a plain object from an Instance message. Also converts values to other types if specified. + * @param message Instance + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.run.v2.Instance, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Instance to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Instance + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of an InstanceSplit. */ interface IInstanceSplit { diff --git a/packages/google-cloud-run/protos/protos.js b/packages/google-cloud-run/protos/protos.js index b48c78d75de..c7edd21ba6b 100644 --- a/packages/google-cloud-run/protos/protos.js +++ b/packages/google-cloud-run/protos/protos.js @@ -2587,6 +2587,235 @@ return Condition; })(); + v2.ContainerStatus = (function() { + + /** + * Properties of a ContainerStatus. + * @memberof google.cloud.run.v2 + * @interface IContainerStatus + * @property {string|null} [name] ContainerStatus name + * @property {string|null} [imageDigest] ContainerStatus imageDigest + */ + + /** + * Constructs a new ContainerStatus. + * @memberof google.cloud.run.v2 + * @classdesc Represents a ContainerStatus. + * @implements IContainerStatus + * @constructor + * @param {google.cloud.run.v2.IContainerStatus=} [properties] Properties to set + */ + function ContainerStatus(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]]; + } + + /** + * ContainerStatus name. + * @member {string} name + * @memberof google.cloud.run.v2.ContainerStatus + * @instance + */ + ContainerStatus.prototype.name = ""; + + /** + * ContainerStatus imageDigest. + * @member {string} imageDigest + * @memberof google.cloud.run.v2.ContainerStatus + * @instance + */ + ContainerStatus.prototype.imageDigest = ""; + + /** + * Creates a new ContainerStatus instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {google.cloud.run.v2.IContainerStatus=} [properties] Properties to set + * @returns {google.cloud.run.v2.ContainerStatus} ContainerStatus instance + */ + ContainerStatus.create = function create(properties) { + return new ContainerStatus(properties); + }; + + /** + * Encodes the specified ContainerStatus message. Does not implicitly {@link google.cloud.run.v2.ContainerStatus.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {google.cloud.run.v2.IContainerStatus} message ContainerStatus message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContainerStatus.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.imageDigest != null && Object.hasOwnProperty.call(message, "imageDigest")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.imageDigest); + return writer; + }; + + /** + * Encodes the specified ContainerStatus message, length delimited. Does not implicitly {@link google.cloud.run.v2.ContainerStatus.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {google.cloud.run.v2.IContainerStatus} message ContainerStatus message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContainerStatus.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ContainerStatus message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.ContainerStatus} ContainerStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContainerStatus.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.ContainerStatus(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.imageDigest = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ContainerStatus message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.ContainerStatus} ContainerStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContainerStatus.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ContainerStatus message. + * @function verify + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ContainerStatus.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.imageDigest != null && message.hasOwnProperty("imageDigest")) + if (!$util.isString(message.imageDigest)) + return "imageDigest: string expected"; + return null; + }; + + /** + * Creates a ContainerStatus message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.ContainerStatus} ContainerStatus + */ + ContainerStatus.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.ContainerStatus) + return object; + var message = new $root.google.cloud.run.v2.ContainerStatus(); + if (object.name != null) + message.name = String(object.name); + if (object.imageDigest != null) + message.imageDigest = String(object.imageDigest); + return message; + }; + + /** + * Creates a plain object from a ContainerStatus message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {google.cloud.run.v2.ContainerStatus} message ContainerStatus + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ContainerStatus.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.imageDigest = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.imageDigest != null && message.hasOwnProperty("imageDigest")) + object.imageDigest = message.imageDigest; + return object; + }; + + /** + * Converts this ContainerStatus to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.ContainerStatus + * @instance + * @returns {Object.} JSON object + */ + ContainerStatus.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ContainerStatus + * @function getTypeUrl + * @memberof google.cloud.run.v2.ContainerStatus + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ContainerStatus.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.ContainerStatus"; + }; + + return ContainerStatus; + })(); + v2.Executions = (function() { /** @@ -5563,6 +5792,7 @@ * @property {string|null} [workingDir] Container workingDir * @property {google.cloud.run.v2.IProbe|null} [livenessProbe] Container livenessProbe * @property {google.cloud.run.v2.IProbe|null} [startupProbe] Container startupProbe + * @property {google.cloud.run.v2.IProbe|null} [readinessProbe] Container readinessProbe * @property {Array.|null} [dependsOn] Container dependsOn * @property {string|null} [baseImageUri] Container baseImageUri * @property {google.cloud.run.v2.IBuildInfo|null} [buildInfo] Container buildInfo @@ -5685,6 +5915,14 @@ */ Container.prototype.startupProbe = null; + /** + * Container readinessProbe. + * @member {google.cloud.run.v2.IProbe|null|undefined} readinessProbe + * @memberof google.cloud.run.v2.Container + * @instance + */ + Container.prototype.readinessProbe = null; + /** * Container dependsOn. * @member {Array.} dependsOn @@ -5765,6 +6003,8 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.dependsOn[i]); if (message.baseImageUri != null && Object.hasOwnProperty.call(message, "baseImageUri")) writer.uint32(/* id 13, wireType 2 =*/106).string(message.baseImageUri); + if (message.readinessProbe != null && Object.hasOwnProperty.call(message, "readinessProbe")) + $root.google.cloud.run.v2.Probe.encode(message.readinessProbe, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); if (message.buildInfo != null && Object.hasOwnProperty.call(message, "buildInfo")) $root.google.cloud.run.v2.BuildInfo.encode(message.buildInfo, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); if (message.sourceCode != null && Object.hasOwnProperty.call(message, "sourceCode")) @@ -5863,6 +6103,10 @@ message.startupProbe = $root.google.cloud.run.v2.Probe.decode(reader, reader.uint32()); break; } + case 14: { + message.readinessProbe = $root.google.cloud.run.v2.Probe.decode(reader, reader.uint32()); + break; + } case 12: { if (!(message.dependsOn && message.dependsOn.length)) message.dependsOn = []; @@ -5982,6 +6226,11 @@ if (error) return "startupProbe." + error; } + if (message.readinessProbe != null && message.hasOwnProperty("readinessProbe")) { + var error = $root.google.cloud.run.v2.Probe.verify(message.readinessProbe); + if (error) + return "readinessProbe." + error; + } if (message.dependsOn != null && message.hasOwnProperty("dependsOn")) { if (!Array.isArray(message.dependsOn)) return "dependsOn: array expected"; @@ -6082,6 +6331,11 @@ throw TypeError(".google.cloud.run.v2.Container.startupProbe: object expected"); message.startupProbe = $root.google.cloud.run.v2.Probe.fromObject(object.startupProbe); } + if (object.readinessProbe != null) { + if (typeof object.readinessProbe !== "object") + throw TypeError(".google.cloud.run.v2.Container.readinessProbe: object expected"); + message.readinessProbe = $root.google.cloud.run.v2.Probe.fromObject(object.readinessProbe); + } if (object.dependsOn) { if (!Array.isArray(object.dependsOn)) throw TypeError(".google.cloud.run.v2.Container.dependsOn: array expected"); @@ -6128,6 +6382,7 @@ object.livenessProbe = null; object.startupProbe = null; object.baseImageUri = ""; + object.readinessProbe = null; object.buildInfo = null; object.sourceCode = null; } @@ -6175,6 +6430,8 @@ } if (message.baseImageUri != null && message.hasOwnProperty("baseImageUri")) object.baseImageUri = message.baseImageUri; + if (message.readinessProbe != null && message.hasOwnProperty("readinessProbe")) + object.readinessProbe = $root.google.cloud.run.v2.Probe.toObject(message.readinessProbe, options); if (message.buildInfo != null && message.hasOwnProperty("buildInfo")) object.buildInfo = $root.google.cloud.run.v2.BuildInfo.toObject(message.buildInfo, options); if (message.sourceCode != null && message.hasOwnProperty("sourceCode")) @@ -14575,6 +14832,3406 @@ return ExecutionTemplate; })(); + v2.Instances = (function() { + + /** + * Constructs a new Instances service. + * @memberof google.cloud.run.v2 + * @classdesc Represents an Instances + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Instances(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Instances.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Instances; + + /** + * Creates new Instances service using the specified rpc implementation. + * @function create + * @memberof google.cloud.run.v2.Instances + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {Instances} RPC service. Useful where requests and/or responses are streamed. + */ + Instances.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|createInstance}. + * @memberof google.cloud.run.v2.Instances + * @typedef CreateInstanceCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateInstance. + * @function createInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.ICreateInstanceRequest} request CreateInstanceRequest message or plain object + * @param {google.cloud.run.v2.Instances.CreateInstanceCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Instances.prototype.createInstance = function createInstance(request, callback) { + return this.rpcCall(createInstance, $root.google.cloud.run.v2.CreateInstanceRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateInstance" }); + + /** + * Calls CreateInstance. + * @function createInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.ICreateInstanceRequest} request CreateInstanceRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|deleteInstance}. + * @memberof google.cloud.run.v2.Instances + * @typedef DeleteInstanceCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls DeleteInstance. + * @function deleteInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IDeleteInstanceRequest} request DeleteInstanceRequest message or plain object + * @param {google.cloud.run.v2.Instances.DeleteInstanceCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Instances.prototype.deleteInstance = function deleteInstance(request, callback) { + return this.rpcCall(deleteInstance, $root.google.cloud.run.v2.DeleteInstanceRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "DeleteInstance" }); + + /** + * Calls DeleteInstance. + * @function deleteInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IDeleteInstanceRequest} request DeleteInstanceRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|getInstance}. + * @memberof google.cloud.run.v2.Instances + * @typedef GetInstanceCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.run.v2.Instance} [response] Instance + */ + + /** + * Calls GetInstance. + * @function getInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IGetInstanceRequest} request GetInstanceRequest message or plain object + * @param {google.cloud.run.v2.Instances.GetInstanceCallback} callback Node-style callback called with the error, if any, and Instance + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Instances.prototype.getInstance = function getInstance(request, callback) { + return this.rpcCall(getInstance, $root.google.cloud.run.v2.GetInstanceRequest, $root.google.cloud.run.v2.Instance, request, callback); + }, "name", { value: "GetInstance" }); + + /** + * Calls GetInstance. + * @function getInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IGetInstanceRequest} request GetInstanceRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|listInstances}. + * @memberof google.cloud.run.v2.Instances + * @typedef ListInstancesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.run.v2.ListInstancesResponse} [response] ListInstancesResponse + */ + + /** + * Calls ListInstances. + * @function listInstances + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IListInstancesRequest} request ListInstancesRequest message or plain object + * @param {google.cloud.run.v2.Instances.ListInstancesCallback} callback Node-style callback called with the error, if any, and ListInstancesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Instances.prototype.listInstances = function listInstances(request, callback) { + return this.rpcCall(listInstances, $root.google.cloud.run.v2.ListInstancesRequest, $root.google.cloud.run.v2.ListInstancesResponse, request, callback); + }, "name", { value: "ListInstances" }); + + /** + * Calls ListInstances. + * @function listInstances + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IListInstancesRequest} request ListInstancesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|stopInstance}. + * @memberof google.cloud.run.v2.Instances + * @typedef StopInstanceCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls StopInstance. + * @function stopInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IStopInstanceRequest} request StopInstanceRequest message or plain object + * @param {google.cloud.run.v2.Instances.StopInstanceCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Instances.prototype.stopInstance = function stopInstance(request, callback) { + return this.rpcCall(stopInstance, $root.google.cloud.run.v2.StopInstanceRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "StopInstance" }); + + /** + * Calls StopInstance. + * @function stopInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IStopInstanceRequest} request StopInstanceRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.run.v2.Instances|startInstance}. + * @memberof google.cloud.run.v2.Instances + * @typedef StartInstanceCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls StartInstance. + * @function startInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IStartInstanceRequest} request StartInstanceRequest message or plain object + * @param {google.cloud.run.v2.Instances.StartInstanceCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Instances.prototype.startInstance = function startInstance(request, callback) { + return this.rpcCall(startInstance, $root.google.cloud.run.v2.StartInstanceRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "StartInstance" }); + + /** + * Calls StartInstance. + * @function startInstance + * @memberof google.cloud.run.v2.Instances + * @instance + * @param {google.cloud.run.v2.IStartInstanceRequest} request StartInstanceRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Instances; + })(); + + v2.CreateInstanceRequest = (function() { + + /** + * Properties of a CreateInstanceRequest. + * @memberof google.cloud.run.v2 + * @interface ICreateInstanceRequest + * @property {string|null} [parent] CreateInstanceRequest parent + * @property {google.cloud.run.v2.IInstance|null} [instance] CreateInstanceRequest instance + * @property {string|null} [instanceId] CreateInstanceRequest instanceId + * @property {boolean|null} [validateOnly] CreateInstanceRequest validateOnly + */ + + /** + * Constructs a new CreateInstanceRequest. + * @memberof google.cloud.run.v2 + * @classdesc Represents a CreateInstanceRequest. + * @implements ICreateInstanceRequest + * @constructor + * @param {google.cloud.run.v2.ICreateInstanceRequest=} [properties] Properties to set + */ + function CreateInstanceRequest(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]]; + } + + /** + * CreateInstanceRequest parent. + * @member {string} parent + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @instance + */ + CreateInstanceRequest.prototype.parent = ""; + + /** + * CreateInstanceRequest instance. + * @member {google.cloud.run.v2.IInstance|null|undefined} instance + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @instance + */ + CreateInstanceRequest.prototype.instance = null; + + /** + * CreateInstanceRequest instanceId. + * @member {string} instanceId + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @instance + */ + CreateInstanceRequest.prototype.instanceId = ""; + + /** + * CreateInstanceRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @instance + */ + CreateInstanceRequest.prototype.validateOnly = false; + + /** + * Creates a new CreateInstanceRequest instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @static + * @param {google.cloud.run.v2.ICreateInstanceRequest=} [properties] Properties to set + * @returns {google.cloud.run.v2.CreateInstanceRequest} CreateInstanceRequest instance + */ + CreateInstanceRequest.create = function create(properties) { + return new CreateInstanceRequest(properties); + }; + + /** + * Encodes the specified CreateInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.CreateInstanceRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @static + * @param {google.cloud.run.v2.ICreateInstanceRequest} message CreateInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateInstanceRequest.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.instance != null && Object.hasOwnProperty.call(message, "instance")) + $root.google.cloud.run.v2.Instance.encode(message.instance, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.instanceId != null && Object.hasOwnProperty.call(message, "instanceId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.instanceId); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified CreateInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.CreateInstanceRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @static + * @param {google.cloud.run.v2.ICreateInstanceRequest} message CreateInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateInstanceRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.CreateInstanceRequest} CreateInstanceRequest + * @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, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.CreateInstanceRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.instance = $root.google.cloud.run.v2.Instance.decode(reader, reader.uint32()); + break; + } + case 3: { + message.instanceId = reader.string(); + break; + } + case 4: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateInstanceRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.CreateInstanceRequest} CreateInstanceRequest + * @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) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateInstanceRequest message. + * @function verify + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @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) { + 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.instance != null && message.hasOwnProperty("instance")) { + var error = $root.google.cloud.run.v2.Instance.verify(message.instance); + if (error) + return "instance." + error; + } + if (message.instanceId != null && message.hasOwnProperty("instanceId")) + if (!$util.isString(message.instanceId)) + return "instanceId: string expected"; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates a CreateInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.CreateInstanceRequest} CreateInstanceRequest + */ + CreateInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.CreateInstanceRequest) + return object; + var message = new $root.google.cloud.run.v2.CreateInstanceRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.instance != null) { + if (typeof object.instance !== "object") + throw TypeError(".google.cloud.run.v2.CreateInstanceRequest.instance: object expected"); + message.instance = $root.google.cloud.run.v2.Instance.fromObject(object.instance); + } + if (object.instanceId != null) + message.instanceId = String(object.instanceId); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from a CreateInstanceRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @static + * @param {google.cloud.run.v2.CreateInstanceRequest} message CreateInstanceRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateInstanceRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.instance = null; + object.instanceId = ""; + object.validateOnly = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.instance != null && message.hasOwnProperty("instance")) + object.instance = $root.google.cloud.run.v2.Instance.toObject(message.instance, options); + if (message.instanceId != null && message.hasOwnProperty("instanceId")) + object.instanceId = message.instanceId; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this CreateInstanceRequest to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @instance + * @returns {Object.} JSON object + */ + CreateInstanceRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateInstanceRequest + * @function getTypeUrl + * @memberof google.cloud.run.v2.CreateInstanceRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.CreateInstanceRequest"; + }; + + return CreateInstanceRequest; + })(); + + v2.GetInstanceRequest = (function() { + + /** + * Properties of a GetInstanceRequest. + * @memberof google.cloud.run.v2 + * @interface IGetInstanceRequest + * @property {string|null} [name] GetInstanceRequest name + */ + + /** + * Constructs a new GetInstanceRequest. + * @memberof google.cloud.run.v2 + * @classdesc Represents a GetInstanceRequest. + * @implements IGetInstanceRequest + * @constructor + * @param {google.cloud.run.v2.IGetInstanceRequest=} [properties] Properties to set + */ + function GetInstanceRequest(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]]; + } + + /** + * GetInstanceRequest name. + * @member {string} name + * @memberof google.cloud.run.v2.GetInstanceRequest + * @instance + */ + GetInstanceRequest.prototype.name = ""; + + /** + * Creates a new GetInstanceRequest instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.GetInstanceRequest + * @static + * @param {google.cloud.run.v2.IGetInstanceRequest=} [properties] Properties to set + * @returns {google.cloud.run.v2.GetInstanceRequest} GetInstanceRequest instance + */ + GetInstanceRequest.create = function create(properties) { + return new GetInstanceRequest(properties); + }; + + /** + * Encodes the specified GetInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.GetInstanceRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.GetInstanceRequest + * @static + * @param {google.cloud.run.v2.IGetInstanceRequest} message GetInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetInstanceRequest.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 GetInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.GetInstanceRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.GetInstanceRequest + * @static + * @param {google.cloud.run.v2.IGetInstanceRequest} message GetInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetInstanceRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.GetInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.GetInstanceRequest} GetInstanceRequest + * @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, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.GetInstanceRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetInstanceRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.GetInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.GetInstanceRequest} GetInstanceRequest + * @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) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetInstanceRequest message. + * @function verify + * @memberof google.cloud.run.v2.GetInstanceRequest + * @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) { + 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 GetInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.GetInstanceRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.GetInstanceRequest} GetInstanceRequest + */ + GetInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.GetInstanceRequest) + return object; + var message = new $root.google.cloud.run.v2.GetInstanceRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetInstanceRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.GetInstanceRequest + * @static + * @param {google.cloud.run.v2.GetInstanceRequest} message GetInstanceRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetInstanceRequest.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 GetInstanceRequest to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.GetInstanceRequest + * @instance + * @returns {Object.} JSON object + */ + GetInstanceRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetInstanceRequest + * @function getTypeUrl + * @memberof google.cloud.run.v2.GetInstanceRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.GetInstanceRequest"; + }; + + return GetInstanceRequest; + })(); + + v2.DeleteInstanceRequest = (function() { + + /** + * Properties of a DeleteInstanceRequest. + * @memberof google.cloud.run.v2 + * @interface IDeleteInstanceRequest + * @property {string|null} [name] DeleteInstanceRequest name + * @property {boolean|null} [validateOnly] DeleteInstanceRequest validateOnly + * @property {string|null} [etag] DeleteInstanceRequest etag + */ + + /** + * Constructs a new DeleteInstanceRequest. + * @memberof google.cloud.run.v2 + * @classdesc Represents a DeleteInstanceRequest. + * @implements IDeleteInstanceRequest + * @constructor + * @param {google.cloud.run.v2.IDeleteInstanceRequest=} [properties] Properties to set + */ + function DeleteInstanceRequest(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]]; + } + + /** + * DeleteInstanceRequest name. + * @member {string} name + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @instance + */ + DeleteInstanceRequest.prototype.name = ""; + + /** + * DeleteInstanceRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @instance + */ + DeleteInstanceRequest.prototype.validateOnly = false; + + /** + * DeleteInstanceRequest etag. + * @member {string} etag + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @instance + */ + DeleteInstanceRequest.prototype.etag = ""; + + /** + * Creates a new DeleteInstanceRequest instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @static + * @param {google.cloud.run.v2.IDeleteInstanceRequest=} [properties] Properties to set + * @returns {google.cloud.run.v2.DeleteInstanceRequest} DeleteInstanceRequest instance + */ + DeleteInstanceRequest.create = function create(properties) { + return new DeleteInstanceRequest(properties); + }; + + /** + * Encodes the specified DeleteInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.DeleteInstanceRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @static + * @param {google.cloud.run.v2.IDeleteInstanceRequest} message DeleteInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteInstanceRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.etag); + return writer; + }; + + /** + * Encodes the specified DeleteInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.DeleteInstanceRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @static + * @param {google.cloud.run.v2.IDeleteInstanceRequest} message DeleteInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteInstanceRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.DeleteInstanceRequest} DeleteInstanceRequest + * @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, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.DeleteInstanceRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 3: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteInstanceRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.DeleteInstanceRequest} DeleteInstanceRequest + * @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) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteInstanceRequest message. + * @function verify + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @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) { + 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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates a DeleteInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.DeleteInstanceRequest} DeleteInstanceRequest + */ + DeleteInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.DeleteInstanceRequest) + return object; + var message = new $root.google.cloud.run.v2.DeleteInstanceRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from a DeleteInstanceRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @static + * @param {google.cloud.run.v2.DeleteInstanceRequest} message DeleteInstanceRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteInstanceRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + return object; + }; + + /** + * Converts this DeleteInstanceRequest to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteInstanceRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteInstanceRequest + * @function getTypeUrl + * @memberof google.cloud.run.v2.DeleteInstanceRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.DeleteInstanceRequest"; + }; + + return DeleteInstanceRequest; + })(); + + v2.ListInstancesRequest = (function() { + + /** + * Properties of a ListInstancesRequest. + * @memberof google.cloud.run.v2 + * @interface IListInstancesRequest + * @property {string|null} [parent] ListInstancesRequest parent + * @property {number|null} [pageSize] ListInstancesRequest pageSize + * @property {string|null} [pageToken] ListInstancesRequest pageToken + * @property {boolean|null} [showDeleted] ListInstancesRequest showDeleted + */ + + /** + * Constructs a new ListInstancesRequest. + * @memberof google.cloud.run.v2 + * @classdesc Represents a ListInstancesRequest. + * @implements IListInstancesRequest + * @constructor + * @param {google.cloud.run.v2.IListInstancesRequest=} [properties] Properties to set + */ + function ListInstancesRequest(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]]; + } + + /** + * ListInstancesRequest parent. + * @member {string} parent + * @memberof google.cloud.run.v2.ListInstancesRequest + * @instance + */ + ListInstancesRequest.prototype.parent = ""; + + /** + * ListInstancesRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.run.v2.ListInstancesRequest + * @instance + */ + ListInstancesRequest.prototype.pageSize = 0; + + /** + * ListInstancesRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.run.v2.ListInstancesRequest + * @instance + */ + ListInstancesRequest.prototype.pageToken = ""; + + /** + * ListInstancesRequest showDeleted. + * @member {boolean} showDeleted + * @memberof google.cloud.run.v2.ListInstancesRequest + * @instance + */ + ListInstancesRequest.prototype.showDeleted = false; + + /** + * Creates a new ListInstancesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.ListInstancesRequest + * @static + * @param {google.cloud.run.v2.IListInstancesRequest=} [properties] Properties to set + * @returns {google.cloud.run.v2.ListInstancesRequest} ListInstancesRequest instance + */ + ListInstancesRequest.create = function create(properties) { + return new ListInstancesRequest(properties); + }; + + /** + * Encodes the specified ListInstancesRequest message. Does not implicitly {@link google.cloud.run.v2.ListInstancesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.ListInstancesRequest + * @static + * @param {google.cloud.run.v2.IListInstancesRequest} message ListInstancesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstancesRequest.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.showDeleted != null && Object.hasOwnProperty.call(message, "showDeleted")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.showDeleted); + return writer; + }; + + /** + * Encodes the specified ListInstancesRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.ListInstancesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.ListInstancesRequest + * @static + * @param {google.cloud.run.v2.IListInstancesRequest} message ListInstancesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstancesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListInstancesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.ListInstancesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.ListInstancesRequest} ListInstancesRequest + * @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, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.ListInstancesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.showDeleted = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListInstancesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.ListInstancesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.ListInstancesRequest} ListInstancesRequest + * @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) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListInstancesRequest message. + * @function verify + * @memberof google.cloud.run.v2.ListInstancesRequest + * @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) { + 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.showDeleted != null && message.hasOwnProperty("showDeleted")) + if (typeof message.showDeleted !== "boolean") + return "showDeleted: boolean expected"; + return null; + }; + + /** + * Creates a ListInstancesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.ListInstancesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.ListInstancesRequest} ListInstancesRequest + */ + ListInstancesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.ListInstancesRequest) + return object; + var message = new $root.google.cloud.run.v2.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.showDeleted != null) + message.showDeleted = Boolean(object.showDeleted); + return message; + }; + + /** + * Creates a plain object from a ListInstancesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.ListInstancesRequest + * @static + * @param {google.cloud.run.v2.ListInstancesRequest} message ListInstancesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListInstancesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.showDeleted = false; + } + 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.showDeleted != null && message.hasOwnProperty("showDeleted")) + object.showDeleted = message.showDeleted; + return object; + }; + + /** + * Converts this ListInstancesRequest to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.ListInstancesRequest + * @instance + * @returns {Object.} JSON object + */ + ListInstancesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListInstancesRequest + * @function getTypeUrl + * @memberof google.cloud.run.v2.ListInstancesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListInstancesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.ListInstancesRequest"; + }; + + return ListInstancesRequest; + })(); + + v2.ListInstancesResponse = (function() { + + /** + * Properties of a ListInstancesResponse. + * @memberof google.cloud.run.v2 + * @interface IListInstancesResponse + * @property {Array.|null} [instances] ListInstancesResponse instances + * @property {string|null} [nextPageToken] ListInstancesResponse nextPageToken + */ + + /** + * Constructs a new ListInstancesResponse. + * @memberof google.cloud.run.v2 + * @classdesc Represents a ListInstancesResponse. + * @implements IListInstancesResponse + * @constructor + * @param {google.cloud.run.v2.IListInstancesResponse=} [properties] Properties to set + */ + function ListInstancesResponse(properties) { + this.instances = []; + 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]]; + } + + /** + * ListInstancesResponse instances. + * @member {Array.} instances + * @memberof google.cloud.run.v2.ListInstancesResponse + * @instance + */ + ListInstancesResponse.prototype.instances = $util.emptyArray; + + /** + * ListInstancesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.run.v2.ListInstancesResponse + * @instance + */ + ListInstancesResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListInstancesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.ListInstancesResponse + * @static + * @param {google.cloud.run.v2.IListInstancesResponse=} [properties] Properties to set + * @returns {google.cloud.run.v2.ListInstancesResponse} ListInstancesResponse instance + */ + ListInstancesResponse.create = function create(properties) { + return new ListInstancesResponse(properties); + }; + + /** + * Encodes the specified ListInstancesResponse message. Does not implicitly {@link google.cloud.run.v2.ListInstancesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.ListInstancesResponse + * @static + * @param {google.cloud.run.v2.IListInstancesResponse} message ListInstancesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstancesResponse.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.cloud.run.v2.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 ListInstancesResponse message, length delimited. Does not implicitly {@link google.cloud.run.v2.ListInstancesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.ListInstancesResponse + * @static + * @param {google.cloud.run.v2.IListInstancesResponse} message ListInstancesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListInstancesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListInstancesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.ListInstancesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.ListInstancesResponse} ListInstancesResponse + * @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, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.ListInstancesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.instances && message.instances.length)) + message.instances = []; + message.instances.push($root.google.cloud.run.v2.Instance.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListInstancesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.ListInstancesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.ListInstancesResponse} ListInstancesResponse + * @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) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListInstancesResponse message. + * @function verify + * @memberof google.cloud.run.v2.ListInstancesResponse + * @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) { + 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.cloud.run.v2.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 ListInstancesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.ListInstancesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.ListInstancesResponse} ListInstancesResponse + */ + ListInstancesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.ListInstancesResponse) + return object; + var message = new $root.google.cloud.run.v2.ListInstancesResponse(); + if (object.instances) { + if (!Array.isArray(object.instances)) + throw TypeError(".google.cloud.run.v2.ListInstancesResponse.instances: array expected"); + message.instances = []; + for (var i = 0; i < object.instances.length; ++i) { + if (typeof object.instances[i] !== "object") + throw TypeError(".google.cloud.run.v2.ListInstancesResponse.instances: object expected"); + message.instances[i] = $root.google.cloud.run.v2.Instance.fromObject(object.instances[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListInstancesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.ListInstancesResponse + * @static + * @param {google.cloud.run.v2.ListInstancesResponse} message ListInstancesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListInstancesResponse.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.cloud.run.v2.Instance.toObject(message.instances[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListInstancesResponse to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.ListInstancesResponse + * @instance + * @returns {Object.} JSON object + */ + ListInstancesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListInstancesResponse + * @function getTypeUrl + * @memberof google.cloud.run.v2.ListInstancesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListInstancesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.ListInstancesResponse"; + }; + + return ListInstancesResponse; + })(); + + v2.StopInstanceRequest = (function() { + + /** + * Properties of a StopInstanceRequest. + * @memberof google.cloud.run.v2 + * @interface IStopInstanceRequest + * @property {string|null} [name] StopInstanceRequest name + * @property {boolean|null} [validateOnly] StopInstanceRequest validateOnly + * @property {string|null} [etag] StopInstanceRequest etag + */ + + /** + * Constructs a new StopInstanceRequest. + * @memberof google.cloud.run.v2 + * @classdesc Represents a StopInstanceRequest. + * @implements IStopInstanceRequest + * @constructor + * @param {google.cloud.run.v2.IStopInstanceRequest=} [properties] Properties to set + */ + function StopInstanceRequest(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]]; + } + + /** + * StopInstanceRequest name. + * @member {string} name + * @memberof google.cloud.run.v2.StopInstanceRequest + * @instance + */ + StopInstanceRequest.prototype.name = ""; + + /** + * StopInstanceRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.run.v2.StopInstanceRequest + * @instance + */ + StopInstanceRequest.prototype.validateOnly = false; + + /** + * StopInstanceRequest etag. + * @member {string} etag + * @memberof google.cloud.run.v2.StopInstanceRequest + * @instance + */ + StopInstanceRequest.prototype.etag = ""; + + /** + * Creates a new StopInstanceRequest instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {google.cloud.run.v2.IStopInstanceRequest=} [properties] Properties to set + * @returns {google.cloud.run.v2.StopInstanceRequest} StopInstanceRequest instance + */ + StopInstanceRequest.create = function create(properties) { + return new StopInstanceRequest(properties); + }; + + /** + * Encodes the specified StopInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.StopInstanceRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {google.cloud.run.v2.IStopInstanceRequest} message StopInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StopInstanceRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.etag); + return writer; + }; + + /** + * Encodes the specified StopInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.StopInstanceRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {google.cloud.run.v2.IStopInstanceRequest} message StopInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StopInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StopInstanceRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.StopInstanceRequest} StopInstanceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StopInstanceRequest.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.StopInstanceRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 3: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StopInstanceRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.StopInstanceRequest} StopInstanceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StopInstanceRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StopInstanceRequest message. + * @function verify + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StopInstanceRequest.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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates a StopInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.StopInstanceRequest} StopInstanceRequest + */ + StopInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.StopInstanceRequest) + return object; + var message = new $root.google.cloud.run.v2.StopInstanceRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from a StopInstanceRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {google.cloud.run.v2.StopInstanceRequest} message StopInstanceRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StopInstanceRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + return object; + }; + + /** + * Converts this StopInstanceRequest to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.StopInstanceRequest + * @instance + * @returns {Object.} JSON object + */ + StopInstanceRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StopInstanceRequest + * @function getTypeUrl + * @memberof google.cloud.run.v2.StopInstanceRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StopInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.StopInstanceRequest"; + }; + + return StopInstanceRequest; + })(); + + v2.StartInstanceRequest = (function() { + + /** + * Properties of a StartInstanceRequest. + * @memberof google.cloud.run.v2 + * @interface IStartInstanceRequest + * @property {string|null} [name] StartInstanceRequest name + * @property {boolean|null} [validateOnly] StartInstanceRequest validateOnly + * @property {string|null} [etag] StartInstanceRequest etag + */ + + /** + * Constructs a new StartInstanceRequest. + * @memberof google.cloud.run.v2 + * @classdesc Represents a StartInstanceRequest. + * @implements IStartInstanceRequest + * @constructor + * @param {google.cloud.run.v2.IStartInstanceRequest=} [properties] Properties to set + */ + function StartInstanceRequest(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]]; + } + + /** + * StartInstanceRequest name. + * @member {string} name + * @memberof google.cloud.run.v2.StartInstanceRequest + * @instance + */ + StartInstanceRequest.prototype.name = ""; + + /** + * StartInstanceRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.run.v2.StartInstanceRequest + * @instance + */ + StartInstanceRequest.prototype.validateOnly = false; + + /** + * StartInstanceRequest etag. + * @member {string} etag + * @memberof google.cloud.run.v2.StartInstanceRequest + * @instance + */ + StartInstanceRequest.prototype.etag = ""; + + /** + * Creates a new StartInstanceRequest instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {google.cloud.run.v2.IStartInstanceRequest=} [properties] Properties to set + * @returns {google.cloud.run.v2.StartInstanceRequest} StartInstanceRequest instance + */ + StartInstanceRequest.create = function create(properties) { + return new StartInstanceRequest(properties); + }; + + /** + * Encodes the specified StartInstanceRequest message. Does not implicitly {@link google.cloud.run.v2.StartInstanceRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {google.cloud.run.v2.IStartInstanceRequest} message StartInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StartInstanceRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.etag); + return writer; + }; + + /** + * Encodes the specified StartInstanceRequest message, length delimited. Does not implicitly {@link google.cloud.run.v2.StartInstanceRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {google.cloud.run.v2.IStartInstanceRequest} message StartInstanceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StartInstanceRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StartInstanceRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.StartInstanceRequest} StartInstanceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StartInstanceRequest.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.StartInstanceRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 3: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StartInstanceRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.StartInstanceRequest} StartInstanceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StartInstanceRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StartInstanceRequest message. + * @function verify + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StartInstanceRequest.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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates a StartInstanceRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.StartInstanceRequest} StartInstanceRequest + */ + StartInstanceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.StartInstanceRequest) + return object; + var message = new $root.google.cloud.run.v2.StartInstanceRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from a StartInstanceRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {google.cloud.run.v2.StartInstanceRequest} message StartInstanceRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StartInstanceRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + return object; + }; + + /** + * Converts this StartInstanceRequest to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.StartInstanceRequest + * @instance + * @returns {Object.} JSON object + */ + StartInstanceRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StartInstanceRequest + * @function getTypeUrl + * @memberof google.cloud.run.v2.StartInstanceRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StartInstanceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.StartInstanceRequest"; + }; + + return StartInstanceRequest; + })(); + + v2.Instance = (function() { + + /** + * Properties of an Instance. + * @memberof google.cloud.run.v2 + * @interface IInstance + * @property {string|null} [name] Instance name + * @property {string|null} [description] Instance description + * @property {string|null} [uid] Instance uid + * @property {number|Long|null} [generation] Instance generation + * @property {Object.|null} [labels] Instance labels + * @property {Object.|null} [annotations] Instance annotations + * @property {google.protobuf.ITimestamp|null} [createTime] Instance createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] Instance updateTime + * @property {google.protobuf.ITimestamp|null} [deleteTime] Instance deleteTime + * @property {google.protobuf.ITimestamp|null} [expireTime] Instance expireTime + * @property {string|null} [creator] Instance creator + * @property {string|null} [lastModifier] Instance lastModifier + * @property {string|null} [client] Instance client + * @property {string|null} [clientVersion] Instance clientVersion + * @property {google.api.LaunchStage|null} [launchStage] Instance launchStage + * @property {google.cloud.run.v2.IBinaryAuthorization|null} [binaryAuthorization] Instance binaryAuthorization + * @property {google.cloud.run.v2.IVpcAccess|null} [vpcAccess] Instance vpcAccess + * @property {string|null} [serviceAccount] Instance serviceAccount + * @property {Array.|null} [containers] Instance containers + * @property {Array.|null} [volumes] Instance volumes + * @property {string|null} [encryptionKey] Instance encryptionKey + * @property {google.cloud.run.v2.EncryptionKeyRevocationAction|null} [encryptionKeyRevocationAction] Instance encryptionKeyRevocationAction + * @property {google.protobuf.IDuration|null} [encryptionKeyShutdownDuration] Instance encryptionKeyShutdownDuration + * @property {google.cloud.run.v2.INodeSelector|null} [nodeSelector] Instance nodeSelector + * @property {boolean|null} [gpuZonalRedundancyDisabled] Instance gpuZonalRedundancyDisabled + * @property {google.cloud.run.v2.IngressTraffic|null} [ingress] Instance ingress + * @property {boolean|null} [invokerIamDisabled] Instance invokerIamDisabled + * @property {boolean|null} [iapEnabled] Instance iapEnabled + * @property {number|Long|null} [observedGeneration] Instance observedGeneration + * @property {string|null} [logUri] Instance logUri + * @property {google.cloud.run.v2.ICondition|null} [terminalCondition] Instance terminalCondition + * @property {Array.|null} [conditions] Instance conditions + * @property {Array.|null} [containerStatuses] Instance containerStatuses + * @property {boolean|null} [satisfiesPzs] Instance satisfiesPzs + * @property {Array.|null} [urls] Instance urls + * @property {boolean|null} [reconciling] Instance reconciling + * @property {string|null} [etag] Instance etag + */ + + /** + * Constructs a new Instance. + * @memberof google.cloud.run.v2 + * @classdesc Represents an Instance. + * @implements IInstance + * @constructor + * @param {google.cloud.run.v2.IInstance=} [properties] Properties to set + */ + function Instance(properties) { + this.labels = {}; + this.annotations = {}; + this.containers = []; + this.volumes = []; + this.conditions = []; + this.containerStatuses = []; + this.urls = []; + 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]]; + } + + /** + * Instance name. + * @member {string} name + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.name = ""; + + /** + * Instance description. + * @member {string} description + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.description = ""; + + /** + * Instance uid. + * @member {string} uid + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.uid = ""; + + /** + * Instance generation. + * @member {number|Long} generation + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.generation = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Instance labels. + * @member {Object.} labels + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.labels = $util.emptyObject; + + /** + * Instance annotations. + * @member {Object.} annotations + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.annotations = $util.emptyObject; + + /** + * Instance createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.createTime = null; + + /** + * Instance updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.updateTime = null; + + /** + * Instance deleteTime. + * @member {google.protobuf.ITimestamp|null|undefined} deleteTime + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.deleteTime = null; + + /** + * Instance expireTime. + * @member {google.protobuf.ITimestamp|null|undefined} expireTime + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.expireTime = null; + + /** + * Instance creator. + * @member {string} creator + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.creator = ""; + + /** + * Instance lastModifier. + * @member {string} lastModifier + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.lastModifier = ""; + + /** + * Instance client. + * @member {string} client + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.client = ""; + + /** + * Instance clientVersion. + * @member {string} clientVersion + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.clientVersion = ""; + + /** + * Instance launchStage. + * @member {google.api.LaunchStage} launchStage + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.launchStage = 0; + + /** + * Instance binaryAuthorization. + * @member {google.cloud.run.v2.IBinaryAuthorization|null|undefined} binaryAuthorization + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.binaryAuthorization = null; + + /** + * Instance vpcAccess. + * @member {google.cloud.run.v2.IVpcAccess|null|undefined} vpcAccess + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.vpcAccess = null; + + /** + * Instance serviceAccount. + * @member {string} serviceAccount + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.serviceAccount = ""; + + /** + * Instance containers. + * @member {Array.} containers + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.containers = $util.emptyArray; + + /** + * Instance volumes. + * @member {Array.} volumes + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.volumes = $util.emptyArray; + + /** + * Instance encryptionKey. + * @member {string} encryptionKey + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.encryptionKey = ""; + + /** + * Instance encryptionKeyRevocationAction. + * @member {google.cloud.run.v2.EncryptionKeyRevocationAction} encryptionKeyRevocationAction + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.encryptionKeyRevocationAction = 0; + + /** + * Instance encryptionKeyShutdownDuration. + * @member {google.protobuf.IDuration|null|undefined} encryptionKeyShutdownDuration + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.encryptionKeyShutdownDuration = null; + + /** + * Instance nodeSelector. + * @member {google.cloud.run.v2.INodeSelector|null|undefined} nodeSelector + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.nodeSelector = null; + + /** + * Instance gpuZonalRedundancyDisabled. + * @member {boolean|null|undefined} gpuZonalRedundancyDisabled + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.gpuZonalRedundancyDisabled = null; + + /** + * Instance ingress. + * @member {google.cloud.run.v2.IngressTraffic} ingress + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.ingress = 0; + + /** + * Instance invokerIamDisabled. + * @member {boolean} invokerIamDisabled + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.invokerIamDisabled = false; + + /** + * Instance iapEnabled. + * @member {boolean} iapEnabled + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.iapEnabled = false; + + /** + * Instance observedGeneration. + * @member {number|Long} observedGeneration + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.observedGeneration = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Instance logUri. + * @member {string} logUri + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.logUri = ""; + + /** + * Instance terminalCondition. + * @member {google.cloud.run.v2.ICondition|null|undefined} terminalCondition + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.terminalCondition = null; + + /** + * Instance conditions. + * @member {Array.} conditions + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.conditions = $util.emptyArray; + + /** + * Instance containerStatuses. + * @member {Array.} containerStatuses + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.containerStatuses = $util.emptyArray; + + /** + * Instance satisfiesPzs. + * @member {boolean} satisfiesPzs + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.satisfiesPzs = false; + + /** + * Instance urls. + * @member {Array.} urls + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.urls = $util.emptyArray; + + /** + * Instance reconciling. + * @member {boolean} reconciling + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.reconciling = false; + + /** + * Instance etag. + * @member {string} etag + * @memberof google.cloud.run.v2.Instance + * @instance + */ + Instance.prototype.etag = ""; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + // Virtual OneOf for proto3 optional field + Object.defineProperty(Instance.prototype, "_gpuZonalRedundancyDisabled", { + get: $util.oneOfGetter($oneOfFields = ["gpuZonalRedundancyDisabled"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Instance instance using the specified properties. + * @function create + * @memberof google.cloud.run.v2.Instance + * @static + * @param {google.cloud.run.v2.IInstance=} [properties] Properties to set + * @returns {google.cloud.run.v2.Instance} Instance instance + */ + Instance.create = function create(properties) { + return new Instance(properties); + }; + + /** + * Encodes the specified Instance message. Does not implicitly {@link google.cloud.run.v2.Instance.verify|verify} messages. + * @function encode + * @memberof google.cloud.run.v2.Instance + * @static + * @param {google.cloud.run.v2.IInstance} message Instance message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Instance.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.description != null && Object.hasOwnProperty.call(message, "description")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.description); + if (message.uid != null && Object.hasOwnProperty.call(message, "uid")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.uid); + if (message.generation != null && Object.hasOwnProperty.call(message, "generation")) + writer.uint32(/* id 5, wireType 0 =*/40).int64(message.generation); + 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 6, wireType 2 =*/50).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.annotations != null && Object.hasOwnProperty.call(message, "annotations")) + for (var keys = Object.keys(message.annotations), i = 0; i < keys.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.annotations[keys[i]]).ldelim(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.deleteTime != null && Object.hasOwnProperty.call(message, "deleteTime")) + $root.google.protobuf.Timestamp.encode(message.deleteTime, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.expireTime != null && Object.hasOwnProperty.call(message, "expireTime")) + $root.google.protobuf.Timestamp.encode(message.expireTime, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.creator != null && Object.hasOwnProperty.call(message, "creator")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.creator); + if (message.lastModifier != null && Object.hasOwnProperty.call(message, "lastModifier")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.lastModifier); + if (message.client != null && Object.hasOwnProperty.call(message, "client")) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.client); + if (message.clientVersion != null && Object.hasOwnProperty.call(message, "clientVersion")) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.clientVersion); + if (message.launchStage != null && Object.hasOwnProperty.call(message, "launchStage")) + writer.uint32(/* id 16, wireType 0 =*/128).int32(message.launchStage); + if (message.binaryAuthorization != null && Object.hasOwnProperty.call(message, "binaryAuthorization")) + $root.google.cloud.run.v2.BinaryAuthorization.encode(message.binaryAuthorization, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); + if (message.vpcAccess != null && Object.hasOwnProperty.call(message, "vpcAccess")) + $root.google.cloud.run.v2.VpcAccess.encode(message.vpcAccess, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim(); + if (message.serviceAccount != null && Object.hasOwnProperty.call(message, "serviceAccount")) + writer.uint32(/* id 19, wireType 2 =*/154).string(message.serviceAccount); + if (message.containers != null && message.containers.length) + for (var i = 0; i < message.containers.length; ++i) + $root.google.cloud.run.v2.Container.encode(message.containers[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); + if (message.volumes != null && message.volumes.length) + for (var i = 0; i < message.volumes.length; ++i) + $root.google.cloud.run.v2.Volume.encode(message.volumes[i], writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.encryptionKey != null && Object.hasOwnProperty.call(message, "encryptionKey")) + writer.uint32(/* id 22, wireType 2 =*/178).string(message.encryptionKey); + if (message.encryptionKeyRevocationAction != null && Object.hasOwnProperty.call(message, "encryptionKeyRevocationAction")) + writer.uint32(/* id 24, wireType 0 =*/192).int32(message.encryptionKeyRevocationAction); + if (message.encryptionKeyShutdownDuration != null && Object.hasOwnProperty.call(message, "encryptionKeyShutdownDuration")) + $root.google.protobuf.Duration.encode(message.encryptionKeyShutdownDuration, writer.uint32(/* id 25, wireType 2 =*/202).fork()).ldelim(); + if (message.nodeSelector != null && Object.hasOwnProperty.call(message, "nodeSelector")) + $root.google.cloud.run.v2.NodeSelector.encode(message.nodeSelector, writer.uint32(/* id 26, wireType 2 =*/210).fork()).ldelim(); + if (message.gpuZonalRedundancyDisabled != null && Object.hasOwnProperty.call(message, "gpuZonalRedundancyDisabled")) + writer.uint32(/* id 27, wireType 0 =*/216).bool(message.gpuZonalRedundancyDisabled); + if (message.ingress != null && Object.hasOwnProperty.call(message, "ingress")) + writer.uint32(/* id 28, wireType 0 =*/224).int32(message.ingress); + if (message.invokerIamDisabled != null && Object.hasOwnProperty.call(message, "invokerIamDisabled")) + writer.uint32(/* id 29, wireType 0 =*/232).bool(message.invokerIamDisabled); + if (message.iapEnabled != null && Object.hasOwnProperty.call(message, "iapEnabled")) + writer.uint32(/* id 30, wireType 0 =*/240).bool(message.iapEnabled); + if (message.observedGeneration != null && Object.hasOwnProperty.call(message, "observedGeneration")) + writer.uint32(/* id 40, wireType 0 =*/320).int64(message.observedGeneration); + if (message.logUri != null && Object.hasOwnProperty.call(message, "logUri")) + writer.uint32(/* id 41, wireType 2 =*/330).string(message.logUri); + if (message.terminalCondition != null && Object.hasOwnProperty.call(message, "terminalCondition")) + $root.google.cloud.run.v2.Condition.encode(message.terminalCondition, writer.uint32(/* id 42, wireType 2 =*/338).fork()).ldelim(); + if (message.conditions != null && message.conditions.length) + for (var i = 0; i < message.conditions.length; ++i) + $root.google.cloud.run.v2.Condition.encode(message.conditions[i], writer.uint32(/* id 43, wireType 2 =*/346).fork()).ldelim(); + if (message.containerStatuses != null && message.containerStatuses.length) + for (var i = 0; i < message.containerStatuses.length; ++i) + $root.google.cloud.run.v2.ContainerStatus.encode(message.containerStatuses[i], writer.uint32(/* id 44, wireType 2 =*/354).fork()).ldelim(); + if (message.urls != null && message.urls.length) + for (var i = 0; i < message.urls.length; ++i) + writer.uint32(/* id 45, wireType 2 =*/362).string(message.urls[i]); + if (message.satisfiesPzs != null && Object.hasOwnProperty.call(message, "satisfiesPzs")) + writer.uint32(/* id 46, wireType 0 =*/368).bool(message.satisfiesPzs); + if (message.reconciling != null && Object.hasOwnProperty.call(message, "reconciling")) + writer.uint32(/* id 98, wireType 0 =*/784).bool(message.reconciling); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 99, wireType 2 =*/794).string(message.etag); + return writer; + }; + + /** + * Encodes the specified Instance message, length delimited. Does not implicitly {@link google.cloud.run.v2.Instance.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.run.v2.Instance + * @static + * @param {google.cloud.run.v2.IInstance} message Instance message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Instance.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Instance message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.run.v2.Instance + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.run.v2.Instance} Instance + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Instance.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.run.v2.Instance(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 3: { + message.description = reader.string(); + break; + } + case 4: { + message.uid = reader.string(); + break; + } + case 5: { + message.generation = reader.int64(); + break; + } + case 6: { + 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 7: { + if (message.annotations === $util.emptyObject) + message.annotations = {}; + 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.annotations[key] = value; + break; + } + case 8: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 9: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 10: { + message.deleteTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 11: { + message.expireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 12: { + message.creator = reader.string(); + break; + } + case 13: { + message.lastModifier = reader.string(); + break; + } + case 14: { + message.client = reader.string(); + break; + } + case 15: { + message.clientVersion = reader.string(); + break; + } + case 16: { + message.launchStage = reader.int32(); + break; + } + case 17: { + message.binaryAuthorization = $root.google.cloud.run.v2.BinaryAuthorization.decode(reader, reader.uint32()); + break; + } + case 18: { + message.vpcAccess = $root.google.cloud.run.v2.VpcAccess.decode(reader, reader.uint32()); + break; + } + case 19: { + message.serviceAccount = reader.string(); + break; + } + case 20: { + if (!(message.containers && message.containers.length)) + message.containers = []; + message.containers.push($root.google.cloud.run.v2.Container.decode(reader, reader.uint32())); + break; + } + case 21: { + if (!(message.volumes && message.volumes.length)) + message.volumes = []; + message.volumes.push($root.google.cloud.run.v2.Volume.decode(reader, reader.uint32())); + break; + } + case 22: { + message.encryptionKey = reader.string(); + break; + } + case 24: { + message.encryptionKeyRevocationAction = reader.int32(); + break; + } + case 25: { + message.encryptionKeyShutdownDuration = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 26: { + message.nodeSelector = $root.google.cloud.run.v2.NodeSelector.decode(reader, reader.uint32()); + break; + } + case 27: { + message.gpuZonalRedundancyDisabled = reader.bool(); + break; + } + case 28: { + message.ingress = reader.int32(); + break; + } + case 29: { + message.invokerIamDisabled = reader.bool(); + break; + } + case 30: { + message.iapEnabled = reader.bool(); + break; + } + case 40: { + message.observedGeneration = reader.int64(); + break; + } + case 41: { + message.logUri = reader.string(); + break; + } + case 42: { + message.terminalCondition = $root.google.cloud.run.v2.Condition.decode(reader, reader.uint32()); + break; + } + case 43: { + if (!(message.conditions && message.conditions.length)) + message.conditions = []; + message.conditions.push($root.google.cloud.run.v2.Condition.decode(reader, reader.uint32())); + break; + } + case 44: { + if (!(message.containerStatuses && message.containerStatuses.length)) + message.containerStatuses = []; + message.containerStatuses.push($root.google.cloud.run.v2.ContainerStatus.decode(reader, reader.uint32())); + break; + } + case 46: { + message.satisfiesPzs = reader.bool(); + break; + } + case 45: { + if (!(message.urls && message.urls.length)) + message.urls = []; + message.urls.push(reader.string()); + break; + } + case 98: { + message.reconciling = reader.bool(); + break; + } + case 99: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Instance message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.run.v2.Instance + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.run.v2.Instance} Instance + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Instance.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Instance message. + * @function verify + * @memberof google.cloud.run.v2.Instance + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Instance.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.description != null && message.hasOwnProperty("description")) + if (!$util.isString(message.description)) + return "description: string expected"; + if (message.uid != null && message.hasOwnProperty("uid")) + if (!$util.isString(message.uid)) + return "uid: string expected"; + if (message.generation != null && message.hasOwnProperty("generation")) + if (!$util.isInteger(message.generation) && !(message.generation && $util.isInteger(message.generation.low) && $util.isInteger(message.generation.high))) + return "generation: integer|Long 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.annotations != null && message.hasOwnProperty("annotations")) { + if (!$util.isObject(message.annotations)) + return "annotations: object expected"; + var key = Object.keys(message.annotations); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.annotations[key[i]])) + return "annotations: string{k:string} expected"; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.deleteTime != null && message.hasOwnProperty("deleteTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.deleteTime); + if (error) + return "deleteTime." + error; + } + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.expireTime); + if (error) + return "expireTime." + error; + } + if (message.creator != null && message.hasOwnProperty("creator")) + if (!$util.isString(message.creator)) + return "creator: string expected"; + if (message.lastModifier != null && message.hasOwnProperty("lastModifier")) + if (!$util.isString(message.lastModifier)) + return "lastModifier: string expected"; + if (message.client != null && message.hasOwnProperty("client")) + if (!$util.isString(message.client)) + return "client: string expected"; + if (message.clientVersion != null && message.hasOwnProperty("clientVersion")) + if (!$util.isString(message.clientVersion)) + return "clientVersion: string expected"; + if (message.launchStage != null && message.hasOwnProperty("launchStage")) + switch (message.launchStage) { + default: + return "launchStage: enum value expected"; + case 0: + case 6: + case 7: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.binaryAuthorization != null && message.hasOwnProperty("binaryAuthorization")) { + var error = $root.google.cloud.run.v2.BinaryAuthorization.verify(message.binaryAuthorization); + if (error) + return "binaryAuthorization." + error; + } + if (message.vpcAccess != null && message.hasOwnProperty("vpcAccess")) { + var error = $root.google.cloud.run.v2.VpcAccess.verify(message.vpcAccess); + if (error) + return "vpcAccess." + error; + } + if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) + if (!$util.isString(message.serviceAccount)) + return "serviceAccount: string expected"; + if (message.containers != null && message.hasOwnProperty("containers")) { + if (!Array.isArray(message.containers)) + return "containers: array expected"; + for (var i = 0; i < message.containers.length; ++i) { + var error = $root.google.cloud.run.v2.Container.verify(message.containers[i]); + if (error) + return "containers." + error; + } + } + if (message.volumes != null && message.hasOwnProperty("volumes")) { + if (!Array.isArray(message.volumes)) + return "volumes: array expected"; + for (var i = 0; i < message.volumes.length; ++i) { + var error = $root.google.cloud.run.v2.Volume.verify(message.volumes[i]); + if (error) + return "volumes." + error; + } + } + if (message.encryptionKey != null && message.hasOwnProperty("encryptionKey")) + if (!$util.isString(message.encryptionKey)) + return "encryptionKey: string expected"; + if (message.encryptionKeyRevocationAction != null && message.hasOwnProperty("encryptionKeyRevocationAction")) + switch (message.encryptionKeyRevocationAction) { + default: + return "encryptionKeyRevocationAction: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.encryptionKeyShutdownDuration != null && message.hasOwnProperty("encryptionKeyShutdownDuration")) { + var error = $root.google.protobuf.Duration.verify(message.encryptionKeyShutdownDuration); + if (error) + return "encryptionKeyShutdownDuration." + error; + } + if (message.nodeSelector != null && message.hasOwnProperty("nodeSelector")) { + var error = $root.google.cloud.run.v2.NodeSelector.verify(message.nodeSelector); + if (error) + return "nodeSelector." + error; + } + if (message.gpuZonalRedundancyDisabled != null && message.hasOwnProperty("gpuZonalRedundancyDisabled")) { + properties._gpuZonalRedundancyDisabled = 1; + if (typeof message.gpuZonalRedundancyDisabled !== "boolean") + return "gpuZonalRedundancyDisabled: boolean expected"; + } + if (message.ingress != null && message.hasOwnProperty("ingress")) + switch (message.ingress) { + default: + return "ingress: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.invokerIamDisabled != null && message.hasOwnProperty("invokerIamDisabled")) + if (typeof message.invokerIamDisabled !== "boolean") + return "invokerIamDisabled: boolean expected"; + if (message.iapEnabled != null && message.hasOwnProperty("iapEnabled")) + if (typeof message.iapEnabled !== "boolean") + return "iapEnabled: boolean expected"; + if (message.observedGeneration != null && message.hasOwnProperty("observedGeneration")) + if (!$util.isInteger(message.observedGeneration) && !(message.observedGeneration && $util.isInteger(message.observedGeneration.low) && $util.isInteger(message.observedGeneration.high))) + return "observedGeneration: integer|Long expected"; + if (message.logUri != null && message.hasOwnProperty("logUri")) + if (!$util.isString(message.logUri)) + return "logUri: string expected"; + if (message.terminalCondition != null && message.hasOwnProperty("terminalCondition")) { + var error = $root.google.cloud.run.v2.Condition.verify(message.terminalCondition); + if (error) + return "terminalCondition." + error; + } + if (message.conditions != null && message.hasOwnProperty("conditions")) { + if (!Array.isArray(message.conditions)) + return "conditions: array expected"; + for (var i = 0; i < message.conditions.length; ++i) { + var error = $root.google.cloud.run.v2.Condition.verify(message.conditions[i]); + if (error) + return "conditions." + error; + } + } + if (message.containerStatuses != null && message.hasOwnProperty("containerStatuses")) { + if (!Array.isArray(message.containerStatuses)) + return "containerStatuses: array expected"; + for (var i = 0; i < message.containerStatuses.length; ++i) { + var error = $root.google.cloud.run.v2.ContainerStatus.verify(message.containerStatuses[i]); + if (error) + return "containerStatuses." + error; + } + } + if (message.satisfiesPzs != null && message.hasOwnProperty("satisfiesPzs")) + if (typeof message.satisfiesPzs !== "boolean") + return "satisfiesPzs: boolean expected"; + if (message.urls != null && message.hasOwnProperty("urls")) { + if (!Array.isArray(message.urls)) + return "urls: array expected"; + for (var i = 0; i < message.urls.length; ++i) + if (!$util.isString(message.urls[i])) + return "urls: string[] expected"; + } + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + if (typeof message.reconciling !== "boolean") + return "reconciling: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates an Instance message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.run.v2.Instance + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.run.v2.Instance} Instance + */ + Instance.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.run.v2.Instance) + return object; + var message = new $root.google.cloud.run.v2.Instance(); + if (object.name != null) + message.name = String(object.name); + if (object.description != null) + message.description = String(object.description); + if (object.uid != null) + message.uid = String(object.uid); + if (object.generation != null) + if ($util.Long) + (message.generation = $util.Long.fromValue(object.generation)).unsigned = false; + else if (typeof object.generation === "string") + message.generation = parseInt(object.generation, 10); + else if (typeof object.generation === "number") + message.generation = object.generation; + else if (typeof object.generation === "object") + message.generation = new $util.LongBits(object.generation.low >>> 0, object.generation.high >>> 0).toNumber(); + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.run.v2.Instance.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.annotations) { + if (typeof object.annotations !== "object") + throw TypeError(".google.cloud.run.v2.Instance.annotations: object expected"); + message.annotations = {}; + for (var keys = Object.keys(object.annotations), i = 0; i < keys.length; ++i) + message.annotations[keys[i]] = String(object.annotations[keys[i]]); + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.run.v2.Instance.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.run.v2.Instance.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.deleteTime != null) { + if (typeof object.deleteTime !== "object") + throw TypeError(".google.cloud.run.v2.Instance.deleteTime: object expected"); + message.deleteTime = $root.google.protobuf.Timestamp.fromObject(object.deleteTime); + } + if (object.expireTime != null) { + if (typeof object.expireTime !== "object") + throw TypeError(".google.cloud.run.v2.Instance.expireTime: object expected"); + message.expireTime = $root.google.protobuf.Timestamp.fromObject(object.expireTime); + } + if (object.creator != null) + message.creator = String(object.creator); + if (object.lastModifier != null) + message.lastModifier = String(object.lastModifier); + if (object.client != null) + message.client = String(object.client); + if (object.clientVersion != null) + message.clientVersion = String(object.clientVersion); + switch (object.launchStage) { + default: + if (typeof object.launchStage === "number") { + message.launchStage = object.launchStage; + break; + } + break; + case "LAUNCH_STAGE_UNSPECIFIED": + case 0: + message.launchStage = 0; + break; + case "UNIMPLEMENTED": + case 6: + message.launchStage = 6; + break; + case "PRELAUNCH": + case 7: + message.launchStage = 7; + break; + case "EARLY_ACCESS": + case 1: + message.launchStage = 1; + break; + case "ALPHA": + case 2: + message.launchStage = 2; + break; + case "BETA": + case 3: + message.launchStage = 3; + break; + case "GA": + case 4: + message.launchStage = 4; + break; + case "DEPRECATED": + case 5: + message.launchStage = 5; + break; + } + if (object.binaryAuthorization != null) { + if (typeof object.binaryAuthorization !== "object") + throw TypeError(".google.cloud.run.v2.Instance.binaryAuthorization: object expected"); + message.binaryAuthorization = $root.google.cloud.run.v2.BinaryAuthorization.fromObject(object.binaryAuthorization); + } + if (object.vpcAccess != null) { + if (typeof object.vpcAccess !== "object") + throw TypeError(".google.cloud.run.v2.Instance.vpcAccess: object expected"); + message.vpcAccess = $root.google.cloud.run.v2.VpcAccess.fromObject(object.vpcAccess); + } + if (object.serviceAccount != null) + message.serviceAccount = String(object.serviceAccount); + if (object.containers) { + if (!Array.isArray(object.containers)) + throw TypeError(".google.cloud.run.v2.Instance.containers: array expected"); + message.containers = []; + for (var i = 0; i < object.containers.length; ++i) { + if (typeof object.containers[i] !== "object") + throw TypeError(".google.cloud.run.v2.Instance.containers: object expected"); + message.containers[i] = $root.google.cloud.run.v2.Container.fromObject(object.containers[i]); + } + } + if (object.volumes) { + if (!Array.isArray(object.volumes)) + throw TypeError(".google.cloud.run.v2.Instance.volumes: array expected"); + message.volumes = []; + for (var i = 0; i < object.volumes.length; ++i) { + if (typeof object.volumes[i] !== "object") + throw TypeError(".google.cloud.run.v2.Instance.volumes: object expected"); + message.volumes[i] = $root.google.cloud.run.v2.Volume.fromObject(object.volumes[i]); + } + } + if (object.encryptionKey != null) + message.encryptionKey = String(object.encryptionKey); + switch (object.encryptionKeyRevocationAction) { + default: + if (typeof object.encryptionKeyRevocationAction === "number") { + message.encryptionKeyRevocationAction = object.encryptionKeyRevocationAction; + break; + } + break; + case "ENCRYPTION_KEY_REVOCATION_ACTION_UNSPECIFIED": + case 0: + message.encryptionKeyRevocationAction = 0; + break; + case "PREVENT_NEW": + case 1: + message.encryptionKeyRevocationAction = 1; + break; + case "SHUTDOWN": + case 2: + message.encryptionKeyRevocationAction = 2; + break; + } + if (object.encryptionKeyShutdownDuration != null) { + if (typeof object.encryptionKeyShutdownDuration !== "object") + throw TypeError(".google.cloud.run.v2.Instance.encryptionKeyShutdownDuration: object expected"); + message.encryptionKeyShutdownDuration = $root.google.protobuf.Duration.fromObject(object.encryptionKeyShutdownDuration); + } + if (object.nodeSelector != null) { + if (typeof object.nodeSelector !== "object") + throw TypeError(".google.cloud.run.v2.Instance.nodeSelector: object expected"); + message.nodeSelector = $root.google.cloud.run.v2.NodeSelector.fromObject(object.nodeSelector); + } + if (object.gpuZonalRedundancyDisabled != null) + message.gpuZonalRedundancyDisabled = Boolean(object.gpuZonalRedundancyDisabled); + switch (object.ingress) { + default: + if (typeof object.ingress === "number") { + message.ingress = object.ingress; + break; + } + break; + case "INGRESS_TRAFFIC_UNSPECIFIED": + case 0: + message.ingress = 0; + break; + case "INGRESS_TRAFFIC_ALL": + case 1: + message.ingress = 1; + break; + case "INGRESS_TRAFFIC_INTERNAL_ONLY": + case 2: + message.ingress = 2; + break; + case "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER": + case 3: + message.ingress = 3; + break; + case "INGRESS_TRAFFIC_NONE": + case 4: + message.ingress = 4; + break; + } + if (object.invokerIamDisabled != null) + message.invokerIamDisabled = Boolean(object.invokerIamDisabled); + if (object.iapEnabled != null) + message.iapEnabled = Boolean(object.iapEnabled); + if (object.observedGeneration != null) + if ($util.Long) + (message.observedGeneration = $util.Long.fromValue(object.observedGeneration)).unsigned = false; + else if (typeof object.observedGeneration === "string") + message.observedGeneration = parseInt(object.observedGeneration, 10); + else if (typeof object.observedGeneration === "number") + message.observedGeneration = object.observedGeneration; + else if (typeof object.observedGeneration === "object") + message.observedGeneration = new $util.LongBits(object.observedGeneration.low >>> 0, object.observedGeneration.high >>> 0).toNumber(); + if (object.logUri != null) + message.logUri = String(object.logUri); + if (object.terminalCondition != null) { + if (typeof object.terminalCondition !== "object") + throw TypeError(".google.cloud.run.v2.Instance.terminalCondition: object expected"); + message.terminalCondition = $root.google.cloud.run.v2.Condition.fromObject(object.terminalCondition); + } + if (object.conditions) { + if (!Array.isArray(object.conditions)) + throw TypeError(".google.cloud.run.v2.Instance.conditions: array expected"); + message.conditions = []; + for (var i = 0; i < object.conditions.length; ++i) { + if (typeof object.conditions[i] !== "object") + throw TypeError(".google.cloud.run.v2.Instance.conditions: object expected"); + message.conditions[i] = $root.google.cloud.run.v2.Condition.fromObject(object.conditions[i]); + } + } + if (object.containerStatuses) { + if (!Array.isArray(object.containerStatuses)) + throw TypeError(".google.cloud.run.v2.Instance.containerStatuses: array expected"); + message.containerStatuses = []; + for (var i = 0; i < object.containerStatuses.length; ++i) { + if (typeof object.containerStatuses[i] !== "object") + throw TypeError(".google.cloud.run.v2.Instance.containerStatuses: object expected"); + message.containerStatuses[i] = $root.google.cloud.run.v2.ContainerStatus.fromObject(object.containerStatuses[i]); + } + } + if (object.satisfiesPzs != null) + message.satisfiesPzs = Boolean(object.satisfiesPzs); + if (object.urls) { + if (!Array.isArray(object.urls)) + throw TypeError(".google.cloud.run.v2.Instance.urls: array expected"); + message.urls = []; + for (var i = 0; i < object.urls.length; ++i) + message.urls[i] = String(object.urls[i]); + } + if (object.reconciling != null) + message.reconciling = Boolean(object.reconciling); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from an Instance message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.run.v2.Instance + * @static + * @param {google.cloud.run.v2.Instance} message Instance + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Instance.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.containers = []; + object.volumes = []; + object.conditions = []; + object.containerStatuses = []; + object.urls = []; + } + if (options.objects || options.defaults) { + object.labels = {}; + object.annotations = {}; + } + if (options.defaults) { + object.name = ""; + object.description = ""; + object.uid = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.generation = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.generation = options.longs === String ? "0" : 0; + object.createTime = null; + object.updateTime = null; + object.deleteTime = null; + object.expireTime = null; + object.creator = ""; + object.lastModifier = ""; + object.client = ""; + object.clientVersion = ""; + object.launchStage = options.enums === String ? "LAUNCH_STAGE_UNSPECIFIED" : 0; + object.binaryAuthorization = null; + object.vpcAccess = null; + object.serviceAccount = ""; + object.encryptionKey = ""; + object.encryptionKeyRevocationAction = options.enums === String ? "ENCRYPTION_KEY_REVOCATION_ACTION_UNSPECIFIED" : 0; + object.encryptionKeyShutdownDuration = null; + object.nodeSelector = null; + object.ingress = options.enums === String ? "INGRESS_TRAFFIC_UNSPECIFIED" : 0; + object.invokerIamDisabled = false; + object.iapEnabled = false; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.observedGeneration = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.observedGeneration = options.longs === String ? "0" : 0; + object.logUri = ""; + object.terminalCondition = null; + object.satisfiesPzs = false; + object.reconciling = false; + object.etag = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.description != null && message.hasOwnProperty("description")) + object.description = message.description; + if (message.uid != null && message.hasOwnProperty("uid")) + object.uid = message.uid; + if (message.generation != null && message.hasOwnProperty("generation")) + if (typeof message.generation === "number") + object.generation = options.longs === String ? String(message.generation) : message.generation; + else + object.generation = options.longs === String ? $util.Long.prototype.toString.call(message.generation) : options.longs === Number ? new $util.LongBits(message.generation.low >>> 0, message.generation.high >>> 0).toNumber() : message.generation; + 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.annotations && (keys2 = Object.keys(message.annotations)).length) { + object.annotations = {}; + for (var j = 0; j < keys2.length; ++j) + object.annotations[keys2[j]] = message.annotations[keys2[j]]; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.deleteTime != null && message.hasOwnProperty("deleteTime")) + object.deleteTime = $root.google.protobuf.Timestamp.toObject(message.deleteTime, options); + if (message.expireTime != null && message.hasOwnProperty("expireTime")) + object.expireTime = $root.google.protobuf.Timestamp.toObject(message.expireTime, options); + if (message.creator != null && message.hasOwnProperty("creator")) + object.creator = message.creator; + if (message.lastModifier != null && message.hasOwnProperty("lastModifier")) + object.lastModifier = message.lastModifier; + if (message.client != null && message.hasOwnProperty("client")) + object.client = message.client; + if (message.clientVersion != null && message.hasOwnProperty("clientVersion")) + object.clientVersion = message.clientVersion; + if (message.launchStage != null && message.hasOwnProperty("launchStage")) + object.launchStage = options.enums === String ? $root.google.api.LaunchStage[message.launchStage] === undefined ? message.launchStage : $root.google.api.LaunchStage[message.launchStage] : message.launchStage; + if (message.binaryAuthorization != null && message.hasOwnProperty("binaryAuthorization")) + object.binaryAuthorization = $root.google.cloud.run.v2.BinaryAuthorization.toObject(message.binaryAuthorization, options); + if (message.vpcAccess != null && message.hasOwnProperty("vpcAccess")) + object.vpcAccess = $root.google.cloud.run.v2.VpcAccess.toObject(message.vpcAccess, options); + if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) + object.serviceAccount = message.serviceAccount; + if (message.containers && message.containers.length) { + object.containers = []; + for (var j = 0; j < message.containers.length; ++j) + object.containers[j] = $root.google.cloud.run.v2.Container.toObject(message.containers[j], options); + } + if (message.volumes && message.volumes.length) { + object.volumes = []; + for (var j = 0; j < message.volumes.length; ++j) + object.volumes[j] = $root.google.cloud.run.v2.Volume.toObject(message.volumes[j], options); + } + if (message.encryptionKey != null && message.hasOwnProperty("encryptionKey")) + object.encryptionKey = message.encryptionKey; + if (message.encryptionKeyRevocationAction != null && message.hasOwnProperty("encryptionKeyRevocationAction")) + object.encryptionKeyRevocationAction = options.enums === String ? $root.google.cloud.run.v2.EncryptionKeyRevocationAction[message.encryptionKeyRevocationAction] === undefined ? message.encryptionKeyRevocationAction : $root.google.cloud.run.v2.EncryptionKeyRevocationAction[message.encryptionKeyRevocationAction] : message.encryptionKeyRevocationAction; + if (message.encryptionKeyShutdownDuration != null && message.hasOwnProperty("encryptionKeyShutdownDuration")) + object.encryptionKeyShutdownDuration = $root.google.protobuf.Duration.toObject(message.encryptionKeyShutdownDuration, options); + if (message.nodeSelector != null && message.hasOwnProperty("nodeSelector")) + object.nodeSelector = $root.google.cloud.run.v2.NodeSelector.toObject(message.nodeSelector, options); + if (message.gpuZonalRedundancyDisabled != null && message.hasOwnProperty("gpuZonalRedundancyDisabled")) { + object.gpuZonalRedundancyDisabled = message.gpuZonalRedundancyDisabled; + if (options.oneofs) + object._gpuZonalRedundancyDisabled = "gpuZonalRedundancyDisabled"; + } + if (message.ingress != null && message.hasOwnProperty("ingress")) + object.ingress = options.enums === String ? $root.google.cloud.run.v2.IngressTraffic[message.ingress] === undefined ? message.ingress : $root.google.cloud.run.v2.IngressTraffic[message.ingress] : message.ingress; + if (message.invokerIamDisabled != null && message.hasOwnProperty("invokerIamDisabled")) + object.invokerIamDisabled = message.invokerIamDisabled; + if (message.iapEnabled != null && message.hasOwnProperty("iapEnabled")) + object.iapEnabled = message.iapEnabled; + if (message.observedGeneration != null && message.hasOwnProperty("observedGeneration")) + if (typeof message.observedGeneration === "number") + object.observedGeneration = options.longs === String ? String(message.observedGeneration) : message.observedGeneration; + else + object.observedGeneration = options.longs === String ? $util.Long.prototype.toString.call(message.observedGeneration) : options.longs === Number ? new $util.LongBits(message.observedGeneration.low >>> 0, message.observedGeneration.high >>> 0).toNumber() : message.observedGeneration; + if (message.logUri != null && message.hasOwnProperty("logUri")) + object.logUri = message.logUri; + if (message.terminalCondition != null && message.hasOwnProperty("terminalCondition")) + object.terminalCondition = $root.google.cloud.run.v2.Condition.toObject(message.terminalCondition, options); + if (message.conditions && message.conditions.length) { + object.conditions = []; + for (var j = 0; j < message.conditions.length; ++j) + object.conditions[j] = $root.google.cloud.run.v2.Condition.toObject(message.conditions[j], options); + } + if (message.containerStatuses && message.containerStatuses.length) { + object.containerStatuses = []; + for (var j = 0; j < message.containerStatuses.length; ++j) + object.containerStatuses[j] = $root.google.cloud.run.v2.ContainerStatus.toObject(message.containerStatuses[j], options); + } + if (message.urls && message.urls.length) { + object.urls = []; + for (var j = 0; j < message.urls.length; ++j) + object.urls[j] = message.urls[j]; + } + if (message.satisfiesPzs != null && message.hasOwnProperty("satisfiesPzs")) + object.satisfiesPzs = message.satisfiesPzs; + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + object.reconciling = message.reconciling; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + return object; + }; + + /** + * Converts this Instance to JSON. + * @function toJSON + * @memberof google.cloud.run.v2.Instance + * @instance + * @returns {Object.} JSON object + */ + Instance.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Instance + * @function getTypeUrl + * @memberof google.cloud.run.v2.Instance + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Instance.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.run.v2.Instance"; + }; + + return Instance; + })(); + v2.InstanceSplit = (function() { /** diff --git a/packages/google-cloud-run/protos/protos.json b/packages/google-cloud-run/protos/protos.json index eb4062c6337..cdebe0a282b 100644 --- a/packages/google-cloud-run/protos/protos.json +++ b/packages/google-cloud-run/protos/protos.json @@ -351,6 +351,18 @@ } } }, + "ContainerStatus": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "imageDigest": { + "type": "string", + "id": 2 + } + } + }, "Executions": { "options": { "(google.api.default_host)": "run.googleapis.com", @@ -888,6 +900,10 @@ "type": "Probe", "id": 11 }, + "readinessProbe": { + "type": "Probe", + "id": 14 + }, "dependsOn": { "rule": "repeated", "type": "string", @@ -1677,6 +1693,617 @@ } } }, + "Instances": { + "options": { + "(google.api.default_host)": "run.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateInstance": { + "requestType": "CreateInstanceRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*}/instances", + "(google.api.http).body": "instance", + "(google.api.routing).routing_parameters.field": "parent", + "(google.api.routing).routing_parameters.path_template": "projects/*/locations/{location=*}", + "(google.api.method_signature)": "parent,instance", + "(google.longrunning.operation_info).response_type": "Instance", + "(google.longrunning.operation_info).metadata_type": "Instance" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*}/instances", + "body": "instance" + } + }, + { + "(google.api.routing)": { + "routing_parameters": { + "field": "parent", + "path_template": "projects/*/locations/{location=*}" + } + } + }, + { + "(google.api.method_signature)": "parent,instance" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Instance", + "metadata_type": "Instance" + } + } + ] + }, + "DeleteInstance": { + "requestType": "DeleteInstanceRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).delete": "/v2/{name=projects/*/locations/*/instances/*}", + "(google.api.routing).routing_parameters.field": "name", + "(google.api.routing).routing_parameters.path_template": "projects/*/locations/{location=*}/**", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "Instance", + "(google.longrunning.operation_info).metadata_type": "Instance" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2/{name=projects/*/locations/*/instances/*}" + } + }, + { + "(google.api.routing)": { + "routing_parameters": { + "field": "name", + "path_template": "projects/*/locations/{location=*}/**" + } + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Instance", + "metadata_type": "Instance" + } + } + ] + }, + "GetInstance": { + "requestType": "GetInstanceRequest", + "responseType": "Instance", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/instances/*}", + "(google.api.routing).routing_parameters.field": "name", + "(google.api.routing).routing_parameters.path_template": "projects/*/locations/{location=*}/**", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/instances/*}" + } + }, + { + "(google.api.routing)": { + "routing_parameters": { + "field": "name", + "path_template": "projects/*/locations/{location=*}/**" + } + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListInstances": { + "requestType": "ListInstancesRequest", + "responseType": "ListInstancesResponse", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*}/instances", + "(google.api.routing).routing_parameters.field": "parent", + "(google.api.routing).routing_parameters.path_template": "projects/*/locations/{location=*}", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*}/instances" + } + }, + { + "(google.api.routing)": { + "routing_parameters": { + "field": "parent", + "path_template": "projects/*/locations/{location=*}" + } + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "StopInstance": { + "requestType": "StopInstanceRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{name=projects/*/locations/*/instances/*}:stop", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "Instance", + "(google.longrunning.operation_info).metadata_type": "Instance" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{name=projects/*/locations/*/instances/*}:stop", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Instance", + "metadata_type": "Instance" + } + } + ] + }, + "StartInstance": { + "requestType": "StartInstanceRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{name=projects/*/locations/*/instances/*}:start", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "Instance", + "(google.longrunning.operation_info).metadata_type": "Instance" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{name=projects/*/locations/*/instances/*}:start", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Instance", + "metadata_type": "Instance" + } + } + ] + } + } + }, + "CreateInstanceRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "run.googleapis.com/Instance" + } + }, + "instance": { + "type": "Instance", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "instanceId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "validateOnly": { + "type": "bool", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "GetInstanceRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "run.googleapis.com/Instance" + } + } + } + }, + "DeleteInstanceRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "run.googleapis.com/Instance" + } + }, + "validateOnly": { + "type": "bool", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "etag": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListInstancesRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "run.googleapis.com/Instance" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "showDeleted": { + "type": "bool", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListInstancesResponse": { + "fields": { + "instances": { + "rule": "repeated", + "type": "Instance", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "StopInstanceRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "run.googleapis.com/Instance" + } + }, + "validateOnly": { + "type": "bool", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "etag": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "StartInstanceRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "run.googleapis.com/Instance" + } + }, + "validateOnly": { + "type": "bool", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "etag": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "Instance": { + "options": { + "(google.api.resource).type": "run.googleapis.com/Instance", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/instances/{instance}", + "(google.api.resource).plural": "instances", + "(google.api.resource).singular": "instance" + }, + "oneofs": { + "_gpuZonalRedundancyDisabled": { + "oneof": [ + "gpuZonalRedundancyDisabled" + ] + } + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "description": { + "type": "string", + "id": 3 + }, + "uid": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "generation": { + "type": "int64", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 6 + }, + "annotations": { + "keyType": "string", + "type": "string", + "id": 7 + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "deleteTime": { + "type": "google.protobuf.Timestamp", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "expireTime": { + "type": "google.protobuf.Timestamp", + "id": 11, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "creator": { + "type": "string", + "id": 12, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastModifier": { + "type": "string", + "id": 13, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "client": { + "type": "string", + "id": 14 + }, + "clientVersion": { + "type": "string", + "id": 15 + }, + "launchStage": { + "type": "google.api.LaunchStage", + "id": 16 + }, + "binaryAuthorization": { + "type": "BinaryAuthorization", + "id": 17 + }, + "vpcAccess": { + "type": "VpcAccess", + "id": 18, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "serviceAccount": { + "type": "string", + "id": 19 + }, + "containers": { + "rule": "repeated", + "type": "Container", + "id": 20, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "volumes": { + "rule": "repeated", + "type": "Volume", + "id": 21 + }, + "encryptionKey": { + "type": "string", + "id": 22, + "options": { + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey" + } + }, + "encryptionKeyRevocationAction": { + "type": "EncryptionKeyRevocationAction", + "id": 24 + }, + "encryptionKeyShutdownDuration": { + "type": "google.protobuf.Duration", + "id": 25 + }, + "nodeSelector": { + "type": "NodeSelector", + "id": 26, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "gpuZonalRedundancyDisabled": { + "type": "bool", + "id": 27, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "proto3_optional": true + } + }, + "ingress": { + "type": "IngressTraffic", + "id": 28, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "invokerIamDisabled": { + "type": "bool", + "id": 29, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "iapEnabled": { + "type": "bool", + "id": 30, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "observedGeneration": { + "type": "int64", + "id": 40, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "logUri": { + "type": "string", + "id": 41, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "terminalCondition": { + "type": "Condition", + "id": 42, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "conditions": { + "rule": "repeated", + "type": "Condition", + "id": 43, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "containerStatuses": { + "rule": "repeated", + "type": "ContainerStatus", + "id": 44, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "satisfiesPzs": { + "type": "bool", + "id": 46, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "urls": { + "rule": "repeated", + "type": "string", + "id": 45, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "reconciling": { + "type": "bool", + "id": 98, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "etag": { + "type": "string", + "id": 99, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, "InstanceSplit": { "fields": { "type": { diff --git a/packages/google-cloud-run/samples/generated/v2/instances.create_instance.js b/packages/google-cloud-run/samples/generated/v2/instances.create_instance.js new file mode 100644 index 00000000000..1e6dfa06595 --- /dev/null +++ b/packages/google-cloud-run/samples/generated/v2/instances.create_instance.js @@ -0,0 +1,77 @@ +// Copyright 2026 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, instance, instanceId) { + // [START run_v2_generated_Instances_CreateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + */ + // const parent = 'abc123' + /** + */ + // const instance = {} + /** + * Required. The unique identifier for the Instance. It must begin with + * letter, and cannot end with hyphen; must contain fewer than 50 characters. + * The name of the instance becomes {parent}/instances/{instance_id}. + */ + // const instanceId = 'abc123' + /** + * Optional. Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + */ + // const validateOnly = true + + // Imports the Run library + const {InstancesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new InstancesClient(); + + async function callCreateInstance() { + // Construct request + const request = { + parent, + instance, + instanceId, + }; + + // Run request + const [operation] = await runClient.createInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateInstance(); + // [END run_v2_generated_Instances_CreateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-run/samples/generated/v2/instances.delete_instance.js b/packages/google-cloud-run/samples/generated/v2/instances.delete_instance.js new file mode 100644 index 00000000000..bfd242e9bd9 --- /dev/null +++ b/packages/google-cloud-run/samples/generated/v2/instances.delete_instance.js @@ -0,0 +1,71 @@ +// Copyright 2026 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Instances_DeleteInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + */ + // const name = 'abc123' + /** + * Optional. Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * Optional. A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {InstancesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new InstancesClient(); + + async function callDeleteInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteInstance(); + // [END run_v2_generated_Instances_DeleteInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-run/samples/generated/v2/instances.get_instance.js b/packages/google-cloud-run/samples/generated/v2/instances.get_instance.js new file mode 100644 index 00000000000..350d1273ebb --- /dev/null +++ b/packages/google-cloud-run/samples/generated/v2/instances.get_instance.js @@ -0,0 +1,60 @@ +// Copyright 2026 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Instances_GetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + */ + // const name = 'abc123' + + // Imports the Run library + const {InstancesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new InstancesClient(); + + async function callGetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getInstance(request); + console.log(response); + } + + callGetInstance(); + // [END run_v2_generated_Instances_GetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-run/samples/generated/v2/instances.list_instances.js b/packages/google-cloud-run/samples/generated/v2/instances.list_instances.js new file mode 100644 index 00000000000..36050f2cd4d --- /dev/null +++ b/packages/google-cloud-run/samples/generated/v2/instances.list_instances.js @@ -0,0 +1,79 @@ +// Copyright 2026 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START run_v2_generated_Instances_ListInstances_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project to list resources on. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of Instances to return in this call. + */ + // const pageSize = 1234 + /** + * Optional. A page token received from a previous call to ListInstances. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * Optional. If true, returns deleted (but unexpired) resources along with + * active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {InstancesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new InstancesClient(); + + async function callListInstances() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = runClient.listInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstances(); + // [END run_v2_generated_Instances_ListInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-run/samples/generated/v2/instances.start_instance.js b/packages/google-cloud-run/samples/generated/v2/instances.start_instance.js new file mode 100644 index 00000000000..34d808b00af --- /dev/null +++ b/packages/google-cloud-run/samples/generated/v2/instances.start_instance.js @@ -0,0 +1,75 @@ +// Copyright 2026 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Instances_StartInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Instance to stop. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}`, + * where `{project}` can be project id or number. + */ + // const name = 'abc123' + /** + * Optional. Indicates that the request should be validated without actually + * stopping any resources. + */ + // const validateOnly = true + /** + * Optional. A system-generated fingerprint for this version of the resource. + * This may be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {InstancesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new InstancesClient(); + + async function callStartInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.startInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStartInstance(); + // [END run_v2_generated_Instances_StartInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-run/samples/generated/v2/instances.stop_instance.js b/packages/google-cloud-run/samples/generated/v2/instances.stop_instance.js new file mode 100644 index 00000000000..f8ed62f2f31 --- /dev/null +++ b/packages/google-cloud-run/samples/generated/v2/instances.stop_instance.js @@ -0,0 +1,75 @@ +// Copyright 2026 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Instances_StopInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Instance to stop. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}`, + * where `{project}` can be project id or number. + */ + // const name = 'abc123' + /** + * Optional. Indicates that the request should be validated without actually + * stopping any resources. + */ + // const validateOnly = true + /** + * Optional. A system-generated fingerprint for this version of the resource. + * This may be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {InstancesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new InstancesClient(); + + async function callStopInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.stopInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStopInstance(); + // [END run_v2_generated_Instances_StopInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-run/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json b/packages/google-cloud-run/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json index aea9941ab0d..4ff250fc8b5 100644 --- a/packages/google-cloud-run/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json +++ b/packages/google-cloud-run/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json @@ -279,6 +279,294 @@ } } }, + { + "regionTag": "run_v2_generated_Instances_CreateInstance_async", + "title": "Builds createInstance Sample", + "origin": "API_DEFINITION", + "description": " Creates an Instance.", + "canonical": true, + "file": "instances.create_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateInstance", + "fullName": "google.cloud.run.v2.Instances.CreateInstance", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": ".google.cloud.run.v2.Instance" + }, + { + "name": "instance_id", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.run.v2.InstancesClient" + }, + "method": { + "shortName": "CreateInstance", + "fullName": "google.cloud.run.v2.Instances.CreateInstance", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.run.v2.Instances" + } + } + } + }, + { + "regionTag": "run_v2_generated_Instances_DeleteInstance_async", + "title": "Builds deleteInstance Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Instance", + "canonical": true, + "file": "instances.delete_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.run.v2.Instances.DeleteInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.run.v2.InstancesClient" + }, + "method": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.run.v2.Instances.DeleteInstance", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.run.v2.Instances" + } + } + } + }, + { + "regionTag": "run_v2_generated_Instances_GetInstance_async", + "title": "Builds getInstance Sample", + "origin": "API_DEFINITION", + "description": " Gets a Instance", + "canonical": true, + "file": "instances.get_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 52, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstance", + "fullName": "google.cloud.run.v2.Instances.GetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Instance", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.run.v2.InstancesClient" + }, + "method": { + "shortName": "GetInstance", + "fullName": "google.cloud.run.v2.Instances.GetInstance", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.run.v2.Instances" + } + } + } + }, + { + "regionTag": "run_v2_generated_Instances_ListInstances_async", + "title": "Builds listInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists Instances. Results are sorted by creation time, descending.", + "canonical": true, + "file": "instances.list_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstances", + "fullName": "google.cloud.run.v2.Instances.ListInstances", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListInstancesResponse", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.run.v2.InstancesClient" + }, + "method": { + "shortName": "ListInstances", + "fullName": "google.cloud.run.v2.Instances.ListInstances", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.run.v2.Instances" + } + } + } + }, + { + "regionTag": "run_v2_generated_Instances_StopInstance_async", + "title": "Builds stopInstance Sample", + "origin": "API_DEFINITION", + "description": " Stops an Instance.", + "canonical": true, + "file": "instances.stop_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopInstance", + "fullName": "google.cloud.run.v2.Instances.StopInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.run.v2.InstancesClient" + }, + "method": { + "shortName": "StopInstance", + "fullName": "google.cloud.run.v2.Instances.StopInstance", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.run.v2.Instances" + } + } + } + }, + { + "regionTag": "run_v2_generated_Instances_StartInstance_async", + "title": "Builds startInstance Sample", + "origin": "API_DEFINITION", + "description": " Starts an Instance.", + "canonical": true, + "file": "instances.start_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StartInstance", + "fullName": "google.cloud.run.v2.Instances.StartInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.run.v2.InstancesClient" + }, + "method": { + "shortName": "StartInstance", + "fullName": "google.cloud.run.v2.Instances.StartInstance", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.run.v2.Instances" + } + } + } + }, { "regionTag": "run_v2_generated_Jobs_CreateJob_async", "title": "Builds createJob Sample", diff --git a/packages/google-cloud-run/src/index.ts b/packages/google-cloud-run/src/index.ts index 4f2780c7a14..3c28cf6bbfb 100644 --- a/packages/google-cloud-run/src/index.ts +++ b/packages/google-cloud-run/src/index.ts @@ -22,6 +22,8 @@ const BuildsClient = v2.BuildsClient; type BuildsClient = v2.BuildsClient; const ExecutionsClient = v2.ExecutionsClient; type ExecutionsClient = v2.ExecutionsClient; +const InstancesClient = v2.InstancesClient; +type InstancesClient = v2.InstancesClient; const JobsClient = v2.JobsClient; type JobsClient = v2.JobsClient; const RevisionsClient = v2.RevisionsClient; @@ -33,7 +35,7 @@ type TasksClient = v2.TasksClient; const WorkerPoolsClient = v2.WorkerPoolsClient; type WorkerPoolsClient = v2.WorkerPoolsClient; -export {v2, BuildsClient, ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient, WorkerPoolsClient}; -export default {v2, BuildsClient, ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient, WorkerPoolsClient}; +export {v2, BuildsClient, ExecutionsClient, InstancesClient, JobsClient, RevisionsClient, ServicesClient, TasksClient, WorkerPoolsClient}; +export default {v2, BuildsClient, ExecutionsClient, InstancesClient, JobsClient, RevisionsClient, ServicesClient, TasksClient, WorkerPoolsClient}; import * as protos from '../protos/protos'; export {protos}; diff --git a/packages/google-cloud-run/src/v2/builds_client.ts b/packages/google-cloud-run/src/v2/builds_client.ts index a7f21132f7e..9cbdf164888 100644 --- a/packages/google-cloud-run/src/v2/builds_client.ts +++ b/packages/google-cloud-run/src/v2/builds_client.ts @@ -186,6 +186,9 @@ export class BuildsClient { executionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), jobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}' ), @@ -618,6 +621,55 @@ export class BuildsClient { return this.pathTemplates.executionPathTemplate.match(executionName).execution; } + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + /** * Return a fully-qualified job resource name string. * diff --git a/packages/google-cloud-run/src/v2/builds_proto_list.json b/packages/google-cloud-run/src/v2/builds_proto_list.json index e4f09a2cfe3..0d5d6ea6137 100644 --- a/packages/google-cloud-run/src/v2/builds_proto_list.json +++ b/packages/google-cloud-run/src/v2/builds_proto_list.json @@ -1,8 +1,10 @@ [ "../../protos/google/cloud/run/v2/build.proto", "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/container_status.proto", "../../protos/google/cloud/run/v2/execution.proto", "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/instance.proto", "../../protos/google/cloud/run/v2/instance_split.proto", "../../protos/google/cloud/run/v2/job.proto", "../../protos/google/cloud/run/v2/k8s.min.proto", diff --git a/packages/google-cloud-run/src/v2/executions_client.ts b/packages/google-cloud-run/src/v2/executions_client.ts index 32b504b2c69..29b7e4871fb 100644 --- a/packages/google-cloud-run/src/v2/executions_client.ts +++ b/packages/google-cloud-run/src/v2/executions_client.ts @@ -187,6 +187,9 @@ export class ExecutionsClient { executionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), jobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}' ), @@ -1306,6 +1309,55 @@ export class ExecutionsClient { return this.pathTemplates.executionPathTemplate.match(executionName).execution; } + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + /** * Return a fully-qualified job resource name string. * diff --git a/packages/google-cloud-run/src/v2/executions_proto_list.json b/packages/google-cloud-run/src/v2/executions_proto_list.json index e4f09a2cfe3..0d5d6ea6137 100644 --- a/packages/google-cloud-run/src/v2/executions_proto_list.json +++ b/packages/google-cloud-run/src/v2/executions_proto_list.json @@ -1,8 +1,10 @@ [ "../../protos/google/cloud/run/v2/build.proto", "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/container_status.proto", "../../protos/google/cloud/run/v2/execution.proto", "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/instance.proto", "../../protos/google/cloud/run/v2/instance_split.proto", "../../protos/google/cloud/run/v2/job.proto", "../../protos/google/cloud/run/v2/k8s.min.proto", diff --git a/packages/google-cloud-run/src/v2/gapic_metadata.json b/packages/google-cloud-run/src/v2/gapic_metadata.json index b8997e7763e..2276e2b6394 100644 --- a/packages/google-cloud-run/src/v2/gapic_metadata.json +++ b/packages/google-cloud-run/src/v2/gapic_metadata.json @@ -87,6 +87,84 @@ } } }, + "Instances": { + "clients": { + "grpc": { + "libraryClient": "InstancesClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "StopInstance": { + "methods": [ + "stopInstance" + ] + }, + "StartInstance": { + "methods": [ + "startInstance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InstancesClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "StopInstance": { + "methods": [ + "stopInstance" + ] + }, + "StartInstance": { + "methods": [ + "startInstance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + } + } + }, "Jobs": { "clients": { "grpc": { diff --git a/packages/google-cloud-run/src/v2/index.ts b/packages/google-cloud-run/src/v2/index.ts index 8e683c63caf..6cc79ce5e90 100644 --- a/packages/google-cloud-run/src/v2/index.ts +++ b/packages/google-cloud-run/src/v2/index.ts @@ -18,6 +18,7 @@ export {BuildsClient} from './builds_client'; export {ExecutionsClient} from './executions_client'; +export {InstancesClient} from './instances_client'; export {JobsClient} from './jobs_client'; export {RevisionsClient} from './revisions_client'; export {ServicesClient} from './services_client'; diff --git a/packages/google-cloud-run/src/v2/instances_client.ts b/packages/google-cloud-run/src/v2/instances_client.ts new file mode 100644 index 00000000000..8f9acb8e849 --- /dev/null +++ b/packages/google-cloud-run/src/v2/instances_client.ts @@ -0,0 +1,2090 @@ +// Copyright 2026 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; + +/** + * Client JSON configuration object, loaded from + * `src/v2/instances_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './instances_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Cloud Run Instances API allows you to manage Cloud Run Instances. + * @class + * @memberof v2 + */ +export class InstancesClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; + private _log = logging.log('run'); + + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + instancesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of InstancesClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 InstancesClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof InstancesClient; + if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { + throw new Error('Please set either universe_domain or universeDomain, but not both.'); + } + const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; + this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + this._servicePath = 'run.' + this._universeDomain; + const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== this._servicePath && !('scopes' in opts)) { + 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 ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = this._servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === this._servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process === 'object' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + ), + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' + ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + taskPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' + ), + workerPoolPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workerPools/{worker_pool}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') + }; + + const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Instance') as gax.protobuf.Type; + const createInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Instance') as gax.protobuf.Type; + const deleteInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Instance') as gax.protobuf.Type; + const deleteInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Instance') as gax.protobuf.Type; + const stopInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Instance') as gax.protobuf.Type; + const stopInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Instance') as gax.protobuf.Type; + const startInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Instance') as gax.protobuf.Type; + const startInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Instance') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceResponse.decode.bind(createInstanceResponse), + createInstanceMetadata.decode.bind(createInstanceMetadata)), + deleteInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteInstanceResponse.decode.bind(deleteInstanceResponse), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + stopInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + stopInstanceResponse.decode.bind(stopInstanceResponse), + stopInstanceMetadata.decode.bind(stopInstanceMetadata)), + startInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + startInstanceResponse.decode.bind(startInstanceResponse), + startInstanceMetadata.decode.bind(startInstanceMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Instances', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.instancesStub) { + return this.instancesStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Instances. + this.instancesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Instances') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Instances, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const instancesStubMethods = + ['createInstance', 'deleteInstance', 'getInstance', 'listInstances', 'stopInstance', 'startInstance']; + for (const methodName of instancesStubMethods) { + const callPromise = this.instancesStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.instancesStub; + } + + /** + * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + } + return 'run.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + } + return 'run.googleapis.com'; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a Instance + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * @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 {@link protos.google.cloud.run.v2.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.get_instance.js + * region_tag:run_v2_generated_Instances_GetInstance_async + */ + getInstance( + request?: protos.google.cloud.run.v2.IGetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IInstance, + protos.google.cloud.run.v2.IGetInstanceRequest|undefined, {}|undefined + ]>; + getInstance( + request: protos.google.cloud.run.v2.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IInstance, + protos.google.cloud.run.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request: protos.google.cloud.run.v2.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.run.v2.IInstance, + protos.google.cloud.run.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request?: protos.google.cloud.run.v2.IGetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IInstance, + protos.google.cloud.run.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IInstance, + protos.google.cloud.run.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IInstance, + protos.google.cloud.run.v2.IGetInstanceRequest|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize().catch(err => {throw err}); + this._log.info('getInstance request %j', request); + const wrappedCallback: Callback< + protos.google.cloud.run.v2.IInstance, + protos.google.cloud.run.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getInstance response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls.getInstance(request, options, wrappedCallback) + ?.then(([response, options, rawResponse]: [ + protos.google.cloud.run.v2.IInstance, + protos.google.cloud.run.v2.IGetInstanceRequest|undefined, + {}|undefined + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }).catch((error: any) => { + if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { + const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + } + throw error; + }); + } + +/** + * Creates an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * @param {google.cloud.run.v2.Instance} request.instance + * @param {string} request.instanceId + * Required. The unique identifier for the Instance. It must begin with + * letter, and cannot end with hyphen; must contain fewer than 50 characters. + * The name of the instance becomes {parent}/instances/{instance_id}. + * @param {boolean} [request.validateOnly] + * Optional. Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.create_instance.js + * region_tag:run_v2_generated_Instances_CreateInstance_async + */ + createInstance( + request?: protos.google.cloud.run.v2.ICreateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createInstance( + request: protos.google.cloud.run.v2.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request: protos.google.cloud.run.v2.ICreateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request?: protos.google.cloud.run.v2.ICreateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + 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 || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize().catch(err => {throw err}); + const wrappedCallback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('createInstance response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('createInstance request %j', request); + return this.innerApiCalls.createInstance(request, options, wrappedCallback) + ?.then(([response, rawResponse, _]: [ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]) => { + this._log.info('createInstance response %j', rawResponse); + return [response, rawResponse, _]; + }); + } +/** + * Check the status of the long running operation returned by `createInstance()`. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.create_instance.js + * region_tag:run_v2_generated_Instances_CreateInstance_async + */ + async checkCreateInstanceProgress(name: string): Promise>{ + this._log.info('createInstance long-running'); + 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.createInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a Instance + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * @param {boolean} [request.validateOnly] + * Optional. Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} [request.etag] + * Optional. A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.delete_instance.js + * region_tag:run_v2_generated_Instances_DeleteInstance_async + */ + deleteInstance( + request?: protos.google.cloud.run.v2.IDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteInstance( + request: protos.google.cloud.run.v2.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request: protos.google.cloud.run.v2.IDeleteInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request?: protos.google.cloud.run.v2.IDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + 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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize().catch(err => {throw err}); + const wrappedCallback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('deleteInstance response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('deleteInstance request %j', request); + return this.innerApiCalls.deleteInstance(request, options, wrappedCallback) + ?.then(([response, rawResponse, _]: [ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]) => { + this._log.info('deleteInstance response %j', rawResponse); + return [response, rawResponse, _]; + }); + } +/** + * Check the status of the long running operation returned by `deleteInstance()`. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.delete_instance.js + * region_tag:run_v2_generated_Instances_DeleteInstance_async + */ + async checkDeleteInstanceProgress(name: string): Promise>{ + this._log.info('deleteInstance long-running'); + 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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Stops an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Instance to stop. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}`, + * where `{project}` can be project id or number. + * @param {boolean} [request.validateOnly] + * Optional. Indicates that the request should be validated without actually + * stopping any resources. + * @param {string} [request.etag] + * Optional. A system-generated fingerprint for this version of the resource. + * This may be used to detect modification conflict during updates. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.stop_instance.js + * region_tag:run_v2_generated_Instances_StopInstance_async + */ + stopInstance( + request?: protos.google.cloud.run.v2.IStopInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + stopInstance( + request: protos.google.cloud.run.v2.IStopInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopInstance( + request: protos.google.cloud.run.v2.IStopInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopInstance( + request?: protos.google.cloud.run.v2.IStopInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + 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({ + 'name': request.name ?? '', + }); + this.initialize().catch(err => {throw err}); + const wrappedCallback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('stopInstance response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('stopInstance request %j', request); + return this.innerApiCalls.stopInstance(request, options, wrappedCallback) + ?.then(([response, rawResponse, _]: [ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]) => { + this._log.info('stopInstance response %j', rawResponse); + return [response, rawResponse, _]; + }); + } +/** + * Check the status of the long running operation returned by `stopInstance()`. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.stop_instance.js + * region_tag:run_v2_generated_Instances_StopInstance_async + */ + async checkStopInstanceProgress(name: string): Promise>{ + this._log.info('stopInstance long-running'); + 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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Instance to stop. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}`, + * where `{project}` can be project id or number. + * @param {boolean} [request.validateOnly] + * Optional. Indicates that the request should be validated without actually + * stopping any resources. + * @param {string} [request.etag] + * Optional. A system-generated fingerprint for this version of the resource. + * This may be used to detect modification conflict during updates. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.start_instance.js + * region_tag:run_v2_generated_Instances_StartInstance_async + */ + startInstance( + request?: protos.google.cloud.run.v2.IStartInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + startInstance( + request: protos.google.cloud.run.v2.IStartInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startInstance( + request: protos.google.cloud.run.v2.IStartInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startInstance( + request?: protos.google.cloud.run.v2.IStartInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + 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({ + 'name': request.name ?? '', + }); + this.initialize().catch(err => {throw err}); + const wrappedCallback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('startInstance response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('startInstance request %j', request); + return this.innerApiCalls.startInstance(request, options, wrappedCallback) + ?.then(([response, rawResponse, _]: [ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]) => { + this._log.info('startInstance response %j', rawResponse); + return [response, rawResponse, _]; + }); + } +/** + * Check the status of the long running operation returned by `startInstance()`. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.start_instance.js + * region_tag:run_v2_generated_Instances_StartInstance_async + */ + async checkStartInstanceProgress(name: string): Promise>{ + this._log.info('startInstance long-running'); + 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.startInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists Instances. Results are sorted by creation time, descending. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + * @param {number} [request.pageSize] + * Optional. Maximum number of Instances to return in this call. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous call to ListInstances. + * All other parameters must match. + * @param {boolean} [request.showDeleted] + * Optional. If true, returns deleted (but unexpired) resources along with + * active ones. + * @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 {@link protos.google.cloud.run.v2.Instance|Instance}. + * 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstances( + request?: protos.google.cloud.run.v2.IListInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IInstance[], + protos.google.cloud.run.v2.IListInstancesRequest|null, + protos.google.cloud.run.v2.IListInstancesResponse + ]>; + listInstances( + request: protos.google.cloud.run.v2.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListInstancesRequest, + protos.google.cloud.run.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.run.v2.IInstance>): void; + listInstances( + request: protos.google.cloud.run.v2.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListInstancesRequest, + protos.google.cloud.run.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.run.v2.IInstance>): void; + listInstances( + request?: protos.google.cloud.run.v2.IListInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListInstancesRequest, + protos.google.cloud.run.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.run.v2.IInstance>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListInstancesRequest, + protos.google.cloud.run.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.run.v2.IInstance>): + Promise<[ + protos.google.cloud.run.v2.IInstance[], + protos.google.cloud.run.v2.IListInstancesRequest|null, + protos.google.cloud.run.v2.IListInstancesResponse + ]>|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize().catch(err => {throw err}); + const wrappedCallback: PaginationCallback< + protos.google.cloud.run.v2.IListInstancesRequest, + protos.google.cloud.run.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.run.v2.IInstance>|undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listInstances values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listInstances request %j', request); + return this.innerApiCalls + .listInstances(request, options, wrappedCallback) + ?.then(([response, input, output]: [ + protos.google.cloud.run.v2.IInstance[], + protos.google.cloud.run.v2.IListInstancesRequest|null, + protos.google.cloud.run.v2.IListInstancesResponse + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }); + } + +/** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + * @param {number} [request.pageSize] + * Optional. Maximum number of Instances to return in this call. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous call to ListInstances. + * All other parameters must match. + * @param {boolean} [request.showDeleted] + * Optional. If true, returns deleted (but unexpired) resources along with + * active ones. + * @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 {@link protos.google.cloud.run.v2.Instance|Instance} 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstancesStream( + request?: protos.google.cloud.run.v2.IListInstancesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('listInstances stream %j', request); + return this.descriptors.page.listInstances.createStream( + this.innerApiCalls.listInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstances`, 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 location and project to list resources on. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + * @param {number} [request.pageSize] + * Optional. Maximum number of Instances to return in this call. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous call to ListInstances. + * All other parameters must match. + * @param {boolean} [request.showDeleted] + * Optional. If true, returns deleted (but unexpired) resources along with + * active ones. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.run.v2.Instance|Instance}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/instances.list_instances.js + * region_tag:run_v2_generated_Instances_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.cloud.run.v2.IListInstancesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('listInstances iterate %j', request); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @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 {@link google.cloud.location.Location | Location}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. 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.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + 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 ?? '', + }); + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified cryptoKey resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} key_ring + * @param {string} crypto_key + * @returns {string} Resource name string. + */ + cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { + return this.pathTemplates.cryptoKeyPathTemplate.render({ + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }); + } + + /** + * Parse the project from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + } + + /** + * Parse the location from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + } + + /** + * Parse the key_ring from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the key_ring. + */ + matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; + } + + /** + * Parse the crypto_key from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the crypto_key. + */ + matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; + } + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,job:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the job from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the job. + */ + matchJobFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).job; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * Return a fully-qualified job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified task resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @param {string} task + * @returns {string} Resource name string. + */ + taskPath(project:string,location:string,job:string,execution:string,task:string) { + return this.pathTemplates.taskPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + task: task, + }); + } + + /** + * Parse the project from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).project; + } + + /** + * Parse the location from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).location; + } + + /** + * Parse the job from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).job; + } + + /** + * Parse the execution from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).execution; + } + + /** + * Parse the task from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task. + */ + matchTaskFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task; + } + + /** + * Return a fully-qualified workerPool resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} worker_pool + * @returns {string} Resource name string. + */ + workerPoolPath(project:string,location:string,workerPool:string) { + return this.pathTemplates.workerPoolPathTemplate.render({ + project: project, + location: location, + worker_pool: workerPool, + }); + } + + /** + * Parse the project from WorkerPool resource. + * + * @param {string} workerPoolName + * A fully-qualified path representing WorkerPool resource. + * @returns {string} A string representing the project. + */ + matchProjectFromWorkerPoolName(workerPoolName: string) { + return this.pathTemplates.workerPoolPathTemplate.match(workerPoolName).project; + } + + /** + * Parse the location from WorkerPool resource. + * + * @param {string} workerPoolName + * A fully-qualified path representing WorkerPool resource. + * @returns {string} A string representing the location. + */ + matchLocationFromWorkerPoolName(workerPoolName: string) { + return this.pathTemplates.workerPoolPathTemplate.match(workerPoolName).location; + } + + /** + * Parse the worker_pool from WorkerPool resource. + * + * @param {string} workerPoolName + * A fully-qualified path representing WorkerPool resource. + * @returns {string} A string representing the worker_pool. + */ + matchWorkerPoolFromWorkerPoolName(workerPoolName: string) { + return this.pathTemplates.workerPoolPathTemplate.match(workerPoolName).worker_pool; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.instancesStub && !this._terminated) { + return this.instancesStub.then(stub => { + this._log.info('ending gRPC channel'); + this._terminated = true; + stub.close(); + this.locationsClient.close().catch(err => {throw err}); + void this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} \ No newline at end of file diff --git a/packages/google-cloud-run/src/v2/instances_client_config.json b/packages/google-cloud-run/src/v2/instances_client_config.json new file mode 100644 index 00000000000..12dcd7909a7 --- /dev/null +++ b/packages/google-cloud-run/src/v2/instances_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.run.v2.Instances": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateInstance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopInstance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartInstance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-run/src/v2/instances_proto_list.json b/packages/google-cloud-run/src/v2/instances_proto_list.json new file mode 100644 index 00000000000..0d5d6ea6137 --- /dev/null +++ b/packages/google-cloud-run/src/v2/instances_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../protos/google/cloud/run/v2/build.proto", + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/container_status.proto", + "../../protos/google/cloud/run/v2/execution.proto", + "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/instance.proto", + "../../protos/google/cloud/run/v2/instance_split.proto", + "../../protos/google/cloud/run/v2/job.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/status.proto", + "../../protos/google/cloud/run/v2/task.proto", + "../../protos/google/cloud/run/v2/task_template.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto", + "../../protos/google/cloud/run/v2/worker_pool.proto", + "../../protos/google/cloud/run/v2/worker_pool_revision_template.proto" +] diff --git a/packages/google-cloud-run/src/v2/jobs_client.ts b/packages/google-cloud-run/src/v2/jobs_client.ts index 5531e004f78..dff326d9416 100644 --- a/packages/google-cloud-run/src/v2/jobs_client.ts +++ b/packages/google-cloud-run/src/v2/jobs_client.ts @@ -187,6 +187,9 @@ export class JobsClient { executionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), jobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}' ), @@ -1945,6 +1948,55 @@ export class JobsClient { return this.pathTemplates.executionPathTemplate.match(executionName).execution; } + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + /** * Return a fully-qualified job resource name string. * diff --git a/packages/google-cloud-run/src/v2/jobs_proto_list.json b/packages/google-cloud-run/src/v2/jobs_proto_list.json index e4f09a2cfe3..0d5d6ea6137 100644 --- a/packages/google-cloud-run/src/v2/jobs_proto_list.json +++ b/packages/google-cloud-run/src/v2/jobs_proto_list.json @@ -1,8 +1,10 @@ [ "../../protos/google/cloud/run/v2/build.proto", "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/container_status.proto", "../../protos/google/cloud/run/v2/execution.proto", "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/instance.proto", "../../protos/google/cloud/run/v2/instance_split.proto", "../../protos/google/cloud/run/v2/job.proto", "../../protos/google/cloud/run/v2/k8s.min.proto", diff --git a/packages/google-cloud-run/src/v2/revisions_client.ts b/packages/google-cloud-run/src/v2/revisions_client.ts index e56fee66c10..c2d97a21619 100644 --- a/packages/google-cloud-run/src/v2/revisions_client.ts +++ b/packages/google-cloud-run/src/v2/revisions_client.ts @@ -190,6 +190,9 @@ export class RevisionsClient { executionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), jobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}' ), @@ -1300,6 +1303,55 @@ export class RevisionsClient { return this.pathTemplates.executionPathTemplate.match(executionName).execution; } + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + /** * Return a fully-qualified job resource name string. * diff --git a/packages/google-cloud-run/src/v2/revisions_proto_list.json b/packages/google-cloud-run/src/v2/revisions_proto_list.json index e4f09a2cfe3..0d5d6ea6137 100644 --- a/packages/google-cloud-run/src/v2/revisions_proto_list.json +++ b/packages/google-cloud-run/src/v2/revisions_proto_list.json @@ -1,8 +1,10 @@ [ "../../protos/google/cloud/run/v2/build.proto", "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/container_status.proto", "../../protos/google/cloud/run/v2/execution.proto", "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/instance.proto", "../../protos/google/cloud/run/v2/instance_split.proto", "../../protos/google/cloud/run/v2/job.proto", "../../protos/google/cloud/run/v2/k8s.min.proto", diff --git a/packages/google-cloud-run/src/v2/services_client.ts b/packages/google-cloud-run/src/v2/services_client.ts index 765e36f4549..3fabf84fd3c 100644 --- a/packages/google-cloud-run/src/v2/services_client.ts +++ b/packages/google-cloud-run/src/v2/services_client.ts @@ -187,6 +187,9 @@ export class ServicesClient { executionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), jobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}' ), @@ -1816,6 +1819,55 @@ export class ServicesClient { return this.pathTemplates.executionPathTemplate.match(executionName).execution; } + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + /** * Return a fully-qualified job resource name string. * diff --git a/packages/google-cloud-run/src/v2/services_proto_list.json b/packages/google-cloud-run/src/v2/services_proto_list.json index e4f09a2cfe3..0d5d6ea6137 100644 --- a/packages/google-cloud-run/src/v2/services_proto_list.json +++ b/packages/google-cloud-run/src/v2/services_proto_list.json @@ -1,8 +1,10 @@ [ "../../protos/google/cloud/run/v2/build.proto", "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/container_status.proto", "../../protos/google/cloud/run/v2/execution.proto", "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/instance.proto", "../../protos/google/cloud/run/v2/instance_split.proto", "../../protos/google/cloud/run/v2/job.proto", "../../protos/google/cloud/run/v2/k8s.min.proto", diff --git a/packages/google-cloud-run/src/v2/tasks_client.ts b/packages/google-cloud-run/src/v2/tasks_client.ts index 664c529070d..38b33a4e5dc 100644 --- a/packages/google-cloud-run/src/v2/tasks_client.ts +++ b/packages/google-cloud-run/src/v2/tasks_client.ts @@ -189,6 +189,9 @@ export class TasksClient { executionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), jobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}' ), @@ -878,6 +881,55 @@ export class TasksClient { return this.pathTemplates.executionPathTemplate.match(executionName).execution; } + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + /** * Return a fully-qualified job resource name string. * diff --git a/packages/google-cloud-run/src/v2/tasks_proto_list.json b/packages/google-cloud-run/src/v2/tasks_proto_list.json index e4f09a2cfe3..0d5d6ea6137 100644 --- a/packages/google-cloud-run/src/v2/tasks_proto_list.json +++ b/packages/google-cloud-run/src/v2/tasks_proto_list.json @@ -1,8 +1,10 @@ [ "../../protos/google/cloud/run/v2/build.proto", "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/container_status.proto", "../../protos/google/cloud/run/v2/execution.proto", "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/instance.proto", "../../protos/google/cloud/run/v2/instance_split.proto", "../../protos/google/cloud/run/v2/job.proto", "../../protos/google/cloud/run/v2/k8s.min.proto", diff --git a/packages/google-cloud-run/src/v2/worker_pools_client.ts b/packages/google-cloud-run/src/v2/worker_pools_client.ts index fd19709aef7..842874cf75c 100644 --- a/packages/google-cloud-run/src/v2/worker_pools_client.ts +++ b/packages/google-cloud-run/src/v2/worker_pools_client.ts @@ -187,6 +187,9 @@ export class WorkerPoolsClient { executionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), jobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/jobs/{job}' ), @@ -1827,6 +1830,55 @@ export class WorkerPoolsClient { return this.pathTemplates.executionPathTemplate.match(executionName).execution; } + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + /** * Return a fully-qualified job resource name string. * diff --git a/packages/google-cloud-run/src/v2/worker_pools_proto_list.json b/packages/google-cloud-run/src/v2/worker_pools_proto_list.json index e4f09a2cfe3..0d5d6ea6137 100644 --- a/packages/google-cloud-run/src/v2/worker_pools_proto_list.json +++ b/packages/google-cloud-run/src/v2/worker_pools_proto_list.json @@ -1,8 +1,10 @@ [ "../../protos/google/cloud/run/v2/build.proto", "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/container_status.proto", "../../protos/google/cloud/run/v2/execution.proto", "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/instance.proto", "../../protos/google/cloud/run/v2/instance_split.proto", "../../protos/google/cloud/run/v2/job.proto", "../../protos/google/cloud/run/v2/k8s.min.proto", diff --git a/packages/google-cloud-run/system-test/fixtures/sample/src/index.js b/packages/google-cloud-run/system-test/fixtures/sample/src/index.js index 18a87d0b3d9..b75bcd5378f 100644 --- a/packages/google-cloud-run/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-run/system-test/fixtures/sample/src/index.js @@ -23,6 +23,7 @@ const run = require('@google-cloud/run'); function main() { const buildsClient = new run.BuildsClient(); const executionsClient = new run.ExecutionsClient(); + const instancesClient = new run.InstancesClient(); const jobsClient = new run.JobsClient(); const revisionsClient = new run.RevisionsClient(); const servicesClient = new run.ServicesClient(); diff --git a/packages/google-cloud-run/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-run/system-test/fixtures/sample/src/index.ts index 7e87907d78b..bdf1cc11f53 100644 --- a/packages/google-cloud-run/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-run/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {BuildsClient, ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient, WorkerPoolsClient} from '@google-cloud/run'; +import {BuildsClient, ExecutionsClient, InstancesClient, JobsClient, RevisionsClient, ServicesClient, TasksClient, WorkerPoolsClient} from '@google-cloud/run'; // check that the client class type name can be used function doStuffWithBuildsClient(client: BuildsClient) { @@ -25,6 +25,9 @@ function doStuffWithBuildsClient(client: BuildsClient) { function doStuffWithExecutionsClient(client: ExecutionsClient) { client.close(); } +function doStuffWithInstancesClient(client: InstancesClient) { + client.close(); +} function doStuffWithJobsClient(client: JobsClient) { client.close(); } @@ -49,6 +52,9 @@ function main() { const executionsClient = new ExecutionsClient(); doStuffWithExecutionsClient(executionsClient); // check that the client instance can be created + const instancesClient = new InstancesClient(); + doStuffWithInstancesClient(instancesClient); + // check that the client instance can be created const jobsClient = new JobsClient(); doStuffWithJobsClient(jobsClient); // check that the client instance can be created diff --git a/packages/google-cloud-run/test/gapic_builds_v2.ts b/packages/google-cloud-run/test/gapic_builds_v2.ts index d52cd1b6cbb..a0a18108510 100644 --- a/packages/google-cloud-run/test/gapic_builds_v2.ts +++ b/packages/google-cloud-run/test/gapic_builds_v2.ts @@ -562,6 +562,52 @@ describe('v2.BuildsClient', () => { }); }); + describe('instance', async () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new buildsModule.v2.BuildsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + describe('job', async () => { const fakePath = "/rendered/path/job"; const expectedParameters = { diff --git a/packages/google-cloud-run/test/gapic_executions_v2.ts b/packages/google-cloud-run/test/gapic_executions_v2.ts index f4f44849a6f..69f44a4308b 100644 --- a/packages/google-cloud-run/test/gapic_executions_v2.ts +++ b/packages/google-cloud-run/test/gapic_executions_v2.ts @@ -1413,6 +1413,52 @@ describe('v2.ExecutionsClient', () => { }); }); + describe('instance', async () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + describe('job', async () => { const fakePath = "/rendered/path/job"; const expectedParameters = { diff --git a/packages/google-cloud-run/test/gapic_instances_v2.ts b/packages/google-cloud-run/test/gapic_instances_v2.ts new file mode 100644 index 00000000000..44f19d237e7 --- /dev/null +++ b/packages/google-cloud-run/test/gapic_instances_v2.ts @@ -0,0 +1,2127 @@ +// Copyright 2026 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as instancesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, LocationProtos} 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) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.InstancesClient', () => { + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new instancesModule.v2.InstancesClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'run.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new instancesModule.v2.InstancesClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, "googleapis.com"); + }); + + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = instancesModule.v2.InstancesClient.servicePath; + assert.strictEqual(servicePath, 'run.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = instancesModule.v2.InstancesClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'run.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new instancesModule.v2.InstancesClient({universeDomain: 'example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'run.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new instancesModule.v2.InstancesClient({universe_domain: 'example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'run.example.com'); + }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new instancesModule.v2.InstancesClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'run.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new instancesModule.v2.InstancesClient({universeDomain: 'configured.example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'run.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { new instancesModule.v2.InstancesClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + }); + + it('has port', () => { + const port = instancesModule.v2.InstancesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new instancesModule.v2.InstancesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new instancesModule.v2.InstancesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.instancesStub, undefined); + await client.initialize(); + assert(client.instancesStub); + }); + + it('has close method for the initialized client', done => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize().catch(err => {throw err}); + assert(client.instancesStub); + client.close().then(() => { + done(); + }).catch(err => {throw err}); + }); + + it('has close method for the non-initialized client', done => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.instancesStub, undefined); + client.close().then(() => { + done(); + }).catch(err => {throw err}); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetInstanceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + 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 () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetInstanceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + 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 () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetInstanceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstance(request), expectedError); + 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 () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetInstanceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedError = new Error('The client has already been closed.'); + client.close().catch(err => {throw err}); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateInstanceRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + 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 instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateInstanceRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + 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|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + 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 instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateInstanceRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + 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 instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateInstanceRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + 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 instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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 instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteInstanceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + 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 () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteInstanceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + 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 call error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteInstanceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteInstance(request), expectedError); + 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 LRO error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteInstanceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + 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 checkDeleteInstanceProgress without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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.checkDeleteInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('stopInstance', () => { + it('invokes stopInstance without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance without error using callback', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopInstance( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance with call error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.stopInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance with LRO error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.stopInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStopInstanceProgress without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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.checkStopInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStopInstanceProgress with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStopInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('startInstance', () => { + it('invokes startInstance without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.startInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance without error using callback', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startInstance( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance with call error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.startInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance with LRO error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.startInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStartInstanceProgress without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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.checkStartInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStartInstanceProgress with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStartInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListInstancesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + 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 () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListInstancesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + 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 () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListInstancesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstances(request), expectedError); + 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 () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListInstancesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Instance[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Instance) => { + 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.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstancesStream with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListInstancesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Instance[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Instance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListInstancesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + generateSampleMessage(new protos.google.cloud.run.v2.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListInstancesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('cryptoKey', async () => { + const fakePath = "/rendered/path/cryptoKey"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + key_ring: "keyRingValue", + crypto_key: "cryptoKeyValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.cryptoKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.cryptoKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('cryptoKeyPath', () => { + const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCryptoKeyName', () => { + const result = client.matchProjectFromCryptoKeyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCryptoKeyName', () => { + const result = client.matchLocationFromCryptoKeyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyRingFromCryptoKeyName', () => { + const result = client.matchKeyRingFromCryptoKeyName(fakePath); + assert.strictEqual(result, "keyRingValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCryptoKeyFromCryptoKeyName', () => { + const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); + assert.strictEqual(result, "cryptoKeyValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('execution', async () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromExecutionName', () => { + const result = client.matchJobFromExecutionName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('instance', async () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('job', async () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', async () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', async () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('revision', async () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', async () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('task', async () => { + const fakePath = "/rendered/path/task"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + task: "taskValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.taskPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskName', () => { + const result = client.matchJobFromTaskName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromTaskName', () => { + const result = client.matchExecutionFromTaskName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, "taskValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('workerPool', async () => { + const fakePath = "/rendered/path/workerPool"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + worker_pool: "workerPoolValue", + }; + const client = new instancesModule.v2.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.workerPoolPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.workerPoolPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('workerPoolPath', () => { + const result = client.workerPoolPath("projectValue", "locationValue", "workerPoolValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.workerPoolPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromWorkerPoolName', () => { + const result = client.matchProjectFromWorkerPoolName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.workerPoolPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromWorkerPoolName', () => { + const result = client.matchLocationFromWorkerPoolName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.workerPoolPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkerPoolFromWorkerPoolName', () => { + const result = client.matchWorkerPoolFromWorkerPoolName(fakePath); + assert.strictEqual(result, "workerPoolValue"); + assert((client.pathTemplates.workerPoolPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/packages/google-cloud-run/test/gapic_jobs_v2.ts b/packages/google-cloud-run/test/gapic_jobs_v2.ts index f3732088b84..014c64087bf 100644 --- a/packages/google-cloud-run/test/gapic_jobs_v2.ts +++ b/packages/google-cloud-run/test/gapic_jobs_v2.ts @@ -2022,6 +2022,52 @@ describe('v2.JobsClient', () => { }); }); + describe('instance', async () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + describe('job', async () => { const fakePath = "/rendered/path/job"; const expectedParameters = { diff --git a/packages/google-cloud-run/test/gapic_revisions_v2.ts b/packages/google-cloud-run/test/gapic_revisions_v2.ts index 46f6cc643d7..19e6f48c13f 100644 --- a/packages/google-cloud-run/test/gapic_revisions_v2.ts +++ b/packages/google-cloud-run/test/gapic_revisions_v2.ts @@ -1298,6 +1298,52 @@ describe('v2.RevisionsClient', () => { }); }); + describe('instance', async () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + describe('job', async () => { const fakePath = "/rendered/path/job"; const expectedParameters = { diff --git a/packages/google-cloud-run/test/gapic_services_v2.ts b/packages/google-cloud-run/test/gapic_services_v2.ts index 8436c6f91e6..5a5ff605ed7 100644 --- a/packages/google-cloud-run/test/gapic_services_v2.ts +++ b/packages/google-cloud-run/test/gapic_services_v2.ts @@ -1872,6 +1872,52 @@ describe('v2.ServicesClient', () => { }); }); + describe('instance', async () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + describe('job', async () => { const fakePath = "/rendered/path/job"; const expectedParameters = { diff --git a/packages/google-cloud-run/test/gapic_tasks_v2.ts b/packages/google-cloud-run/test/gapic_tasks_v2.ts index 88a211f091d..02f293fcb32 100644 --- a/packages/google-cloud-run/test/gapic_tasks_v2.ts +++ b/packages/google-cloud-run/test/gapic_tasks_v2.ts @@ -888,6 +888,52 @@ describe('v2.TasksClient', () => { }); }); + describe('instance', async () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + describe('job', async () => { const fakePath = "/rendered/path/job"; const expectedParameters = { diff --git a/packages/google-cloud-run/test/gapic_worker_pools_v2.ts b/packages/google-cloud-run/test/gapic_worker_pools_v2.ts index 20d7efec56a..f74aef7c940 100644 --- a/packages/google-cloud-run/test/gapic_worker_pools_v2.ts +++ b/packages/google-cloud-run/test/gapic_worker_pools_v2.ts @@ -1872,6 +1872,52 @@ describe('v2.WorkerPoolsClient', () => { }); }); + describe('instance', async () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new workerpoolsModule.v2.WorkerPoolsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + describe('job', async () => { const fakePath = "/rendered/path/job"; const expectedParameters = {